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

◆ CanBeDisinfected()

bool SpawnItemOnLocation::CanBeDisinfected ( )
protected

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

8173{
8174 override bool CanPutAsAttachment(EntityAI parent)
8175 {
8176 return true;
8177 }
8178};
8179
8181{
8182
8183};
8184
8185//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8186
8187class ItemBase extends InventoryItem
8188{
8192
8194
8195 static int m_DebugActionsMask;
8197 // ============================================
8198 // Variable Manipulation System
8199 // ============================================
8200 // Quantity
8201
8202 float m_VarQuantity;
8203 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8205 int m_VarQuantityMin;
8206 int m_VarQuantityMax;
8207 int m_Count;
8208 float m_VarStackMax;
8209 float m_StoreLoadedQuantity = float.LOWEST;
8210 // Wet
8211 float m_VarWet;
8212 float m_VarWetPrev;//for client to know wetness changed during synchronization
8213 float m_VarWetInit;
8214 float m_VarWetMin;
8215 float m_VarWetMax;
8216 // Cleanness
8217 int m_Cleanness;
8218 int m_CleannessInit;
8219 int m_CleannessMin;
8220 int m_CleannessMax;
8221 // impact sounds
8223 bool m_CanPlayImpactSound = true;
8224 float m_ImpactSpeed;
8226 //
8227 float m_HeatIsolation;
8228 float m_ItemModelLength;
8229 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8231 int m_VarLiquidType;
8232 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8233 int m_QuickBarBonus;
8234 bool m_IsBeingPlaced;
8235 bool m_IsHologram;
8236 bool m_IsTakeable;
8237 bool m_ThrowItemOnDrop;
8240 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8241 bool can_this_be_combined; //Check if item can be combined
8242 bool m_CanThisBeSplit; //Check if item can be split
8243 bool m_IsStoreLoad = false;
8244 bool m_CanShowQuantity;
8245 bool m_HasQuantityBar;
8246 protected bool m_CanBeDigged;
8247 protected bool m_IsResultOfSplit
8248
8249 string m_SoundAttType;
8250 // items color variables
8255 //-------------------------------------------------------
8256
8257 // light source managing
8259
8263
8264 //==============================================
8265 // agent system
8266 private int m_AttachedAgents;
8267
8269 void TransferModifiers(PlayerBase reciever);
8270
8271
8272 // Weapons & suppressors particle effects
8276 ref static map<string, int> m_WeaponTypeToID;
8277 static int m_LastRegisteredWeaponID = 0;
8278
8279 // Overheating effects
8281 float m_OverheatingShots;
8282 ref Timer m_CheckOverheating;
8283 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8284 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8285 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8286 ref array <ref OverheatingParticle> m_OverheatingParticles;
8287
8289 protected bool m_HideSelectionsBySlot;
8290
8291 // Admin Log
8292 PluginAdminLog m_AdminLog;
8293
8294 // misc
8295 ref Timer m_PhysDropTimer;
8296
8297 // Attachment Locking variables
8298 ref array<int> m_CompatibleLocks;
8299 protected int m_LockType;
8300 protected ref EffectSound m_LockingSound;
8301 protected string m_LockSoundSet;
8302
8303 // ItemSoundHandler variables
8304 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8305 protected int m_SoundSyncPlay; // id for sound to play
8306 protected int m_SoundSyncStop; // id for sound to stop
8307 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
8308
8310
8311 //temperature
8312 private float m_TemperaturePerQuantityWeight;
8313
8314 // -------------------------------------------------------------------------
8315 void ItemBase()
8316 {
8317 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8321
8322 if (!g_Game.IsDedicatedServer())
8323 {
8324 if (HasMuzzle())
8325 {
8327
8329 {
8331 }
8332 }
8333
8335 m_ActionsInitialize = false;
8336 }
8337
8338 m_OldLocation = null;
8339
8340 if (g_Game.IsServer())
8341 {
8342 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8343 }
8344
8345 if (ConfigIsExisting("headSelectionsToHide"))
8346 {
8348 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8349 }
8350
8351 m_HideSelectionsBySlot = false;
8352 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8353 {
8354 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8355 }
8356
8357 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8358
8359 m_IsResultOfSplit = false;
8360
8362 }
8363
8364 override void InitItemVariables()
8365 {
8366 super.InitItemVariables();
8367
8368 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8369 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8370 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8371 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8372 m_VarStackMax = ConfigGetFloat("varStackMax");
8373 m_Count = ConfigGetInt("count");
8374
8375 m_CanShowQuantity = ConfigGetBool("quantityShow");
8376 m_HasQuantityBar = ConfigGetBool("quantityBar");
8377
8378 m_CleannessInit = ConfigGetInt("varCleannessInit");
8380 m_CleannessMin = ConfigGetInt("varCleannessMin");
8381 m_CleannessMax = ConfigGetInt("varCleannessMax");
8382
8383 m_WantPlayImpactSound = false;
8384 m_ImpactSpeed = 0.0;
8385
8386 m_VarWetInit = ConfigGetFloat("varWetInit");
8388 m_VarWetMin = ConfigGetFloat("varWetMin");
8389 m_VarWetMax = ConfigGetFloat("varWetMax");
8390
8391 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8392 if (IsLiquidContainer() && GetQuantity() != 0)
8394 m_IsBeingPlaced = false;
8395 m_IsHologram = false;
8396 m_IsTakeable = true;
8397 m_CanBeMovedOverride = false;
8401 m_CanBeDigged = ConfigGetBool("canBeDigged");
8402
8403 m_CompatibleLocks = new array<int>();
8404 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8405 m_LockType = ConfigGetInt("lockType");
8406
8407 //Define if item can be split and set ability to be combined accordingly
8408 m_CanThisBeSplit = false;
8409 can_this_be_combined = false;
8410 if (ConfigIsExisting("canBeSplit"))
8411 {
8412 can_this_be_combined = ConfigGetBool("canBeSplit");
8414 }
8415
8416 m_ItemBehaviour = -1;
8417 if (ConfigIsExisting("itemBehaviour"))
8418 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8419
8420 //RegisterNetSyncVariableInt("m_VariablesMask");
8421 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8422 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8423 RegisterNetSyncVariableInt("m_VarLiquidType");
8424 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8425
8426 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8427 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8428 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8429
8430 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8431 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8432 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8433 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8434
8435 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8436 RegisterNetSyncVariableBool("m_IsTakeable");
8437 RegisterNetSyncVariableBool("m_IsHologram");
8438
8441 {
8442 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8443 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8444 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
8445 }
8446
8447 m_LockSoundSet = ConfigGetString("lockSoundSet");
8448
8450 if (ConfigIsExisting("temperaturePerQuantityWeight"))
8451 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
8452
8453 m_SoundSyncSlotID = -1;
8454 }
8455
8456 override int GetQuickBarBonus()
8457 {
8458 return m_QuickBarBonus;
8459 }
8460
8461 void InitializeActions()
8462 {
8464 if (!m_InputActionMap)
8465 {
8467 m_InputActionMap = iam;
8468 SetActions();
8470 }
8471 }
8472
8473 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
8474 {
8476 {
8477 m_ActionsInitialize = true;
8479 }
8480
8481 actions = m_InputActionMap.Get(action_input_type);
8482 }
8483
8484 void SetActions()
8485 {
8486 AddAction(ActionTakeItem);
8487 AddAction(ActionTakeItemToHands);
8488 AddAction(ActionWorldCraft);
8490 AddAction(ActionAttachWithSwitch);
8491 }
8492
8493 void SetActionAnimOverrides(); // Override action animation for specific item
8494
8495 void AddAction(typename actionName)
8496 {
8497 ActionBase action = ActionManagerBase.GetAction(actionName);
8498
8499 if (!action)
8500 {
8501 Debug.LogError("Action " + actionName + " dosn't exist!");
8502 return;
8503 }
8504
8505 typename ai = action.GetInputType();
8506 if (!ai)
8507 {
8508 m_ActionsInitialize = false;
8509 return;
8510 }
8511
8512 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8513 if (!action_array)
8514 {
8515 action_array = new array<ActionBase_Basic>;
8516 m_InputActionMap.Insert(ai, action_array);
8517 }
8518 if (LogManager.IsActionLogEnable())
8519 {
8520 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
8521 }
8522
8523 if (action_array.Find(action) != -1)
8524 {
8525 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
8526 }
8527 else
8528 {
8529 action_array.Insert(action);
8530 }
8531 }
8532
8533 void RemoveAction(typename actionName)
8534 {
8535 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8536 ActionBase action = player.GetActionManager().GetAction(actionName);
8537 typename ai = action.GetInputType();
8538 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8539
8540 if (action_array)
8541 {
8542 action_array.RemoveItem(action);
8543 }
8544 }
8545
8546 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
8547 // Set -1 for params which should stay in default state
8548 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
8549 {
8550 ActionOverrideData overrideData = new ActionOverrideData();
8551 overrideData.m_CommandUID = commandUID;
8552 overrideData.m_CommandUIDProne = commandUIDProne;
8553 overrideData.m_StanceMask = stanceMask;
8554
8555 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
8556 if (!actionMap) // create new map of action > overidables map
8557 {
8558 actionMap = new TActionAnimOverrideMap();
8559 m_ItemActionOverrides.Insert(action, actionMap);
8560 }
8561
8562 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
8563
8564 }
8565
8566 void OnItemInHandsPlayerSwimStart(PlayerBase player);
8567
8568 ScriptedLightBase GetLight();
8569
8570 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8571 void LoadParticleConfigOnFire(int id)
8572 {
8573 if (!m_OnFireEffect)
8575
8578
8579 string config_to_search = "CfgVehicles";
8580 string muzzle_owner_config;
8581
8582 if (!m_OnFireEffect.Contains(id))
8583 {
8584 if (IsInherited(Weapon))
8585 config_to_search = "CfgWeapons";
8586
8587 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8588
8589 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
8590
8591 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
8592
8593 if (config_OnFire_subclass_count > 0)
8594 {
8595 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
8596
8597 for (int i = 0; i < config_OnFire_subclass_count; i++)
8598 {
8599 string particle_class = "";
8600 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
8601 string config_OnFire_entry = config_OnFire_class + particle_class;
8602 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
8603 WPOF_array.Insert(WPOF);
8604 }
8605
8606
8607 m_OnFireEffect.Insert(id, WPOF_array);
8608 }
8609 }
8610
8611 if (!m_OnBulletCasingEjectEffect.Contains(id))
8612 {
8613 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
8614 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8615
8616 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
8617
8618 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
8619
8620 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
8621 {
8622 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
8623
8624 for (i = 0; i < config_OnBulletCasingEject_count; i++)
8625 {
8626 string particle_class2 = "";
8627 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
8628 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
8629 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
8630 WPOBE_array.Insert(WPOBE);
8631 }
8632
8633
8634 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
8635 }
8636 }
8637 }
8638
8639 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8641 {
8644
8645 if (!m_OnOverheatingEffect.Contains(id))
8646 {
8647 string config_to_search = "CfgVehicles";
8648
8649 if (IsInherited(Weapon))
8650 config_to_search = "CfgWeapons";
8651
8652 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
8653 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
8654
8655 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
8656 {
8657
8658 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
8659
8661 {
8662 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
8663 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
8664 Error(error);
8665 return;
8666 }
8667
8668 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
8669 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
8670
8671
8672
8673 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
8674 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
8675
8676 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
8677 {
8678 string particle_class = "";
8679 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
8680 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
8681 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
8682
8683 if (entry_type == CT_CLASS)
8684 {
8685 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
8686 WPOOH_array.Insert(WPOF);
8687 }
8688 }
8689
8690
8691 m_OnOverheatingEffect.Insert(id, WPOOH_array);
8692 }
8693 }
8694 }
8695
8696 float GetOverheatingValue()
8697 {
8698 return m_OverheatingShots;
8699 }
8700
8701 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8702 {
8703 if (m_MaxOverheatingValue > 0)
8704 {
8706
8707 if (!m_CheckOverheating)
8709
8711 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8712
8713 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8714 }
8715 }
8716
8717 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8718 {
8720 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8721
8723 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8724
8726 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8727
8729 {
8731 }
8732 }
8733
8735 {
8737 }
8738
8739 void OnOverheatingDecay()
8740 {
8741 if (m_MaxOverheatingValue > 0)
8742 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8743 else
8745
8746 if (m_OverheatingShots <= 0)
8747 {
8750 }
8751 else
8752 {
8753 if (!m_CheckOverheating)
8755
8757 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8758 }
8759
8760 CheckOverheating(this, "", this);
8761 }
8762
8763 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8764 {
8766 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8767 }
8768
8769 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8770 {
8772 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8774 }
8775
8776 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8777 {
8779 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8780 }
8781
8782 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
8783 {
8785 m_OverheatingParticles = new array<ref OverheatingParticle>;
8786
8787 OverheatingParticle OP = new OverheatingParticle();
8788 OP.RegisterParticle(p);
8789 OP.SetOverheatingLimitMin(min_heat_coef);
8790 OP.SetOverheatingLimitMax(max_heat_coef);
8791 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
8792
8793 m_OverheatingParticles.Insert(OP);
8794 }
8795
8796 float GetOverheatingCoef()
8797 {
8798 if (m_MaxOverheatingValue > 0)
8800
8801 return -1;
8802 }
8803
8805 {
8807 {
8808 float overheat_coef = GetOverheatingCoef();
8809 int count = m_OverheatingParticles.Count();
8810
8811 for (int i = count; i > 0; --i)
8812 {
8813 int id = i - 1;
8814 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8815 Particle p = OP.GetParticle();
8816
8817 float overheat_min = OP.GetOverheatingLimitMin();
8818 float overheat_max = OP.GetOverheatingLimitMax();
8819
8820 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
8821 {
8822 if (p)
8823 {
8824 p.Stop();
8825 OP.RegisterParticle(null);
8826 }
8827 }
8828 }
8829 }
8830 }
8831
8833 {
8835 {
8836 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
8837 {
8838 int id = i - 1;
8839 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8840
8841 if (OP)
8842 {
8843 Particle p = OP.GetParticle();
8844
8845 if (p)
8846 {
8847 p.Stop();
8848 }
8849
8850 delete OP;
8851 }
8852 }
8853
8854 m_OverheatingParticles.Clear();
8856 }
8857 }
8858
8860 float GetInfectionChance(int system = 0, Param param = null)
8861 {
8862 return 0.0;
8863 }
8864
8865
8866 float GetDisinfectQuantity(int system = 0, Param param1 = null)
8867 {
8868 return 250;//default value
8869 }
8870
8871 float GetFilterDamageRatio()
8872 {
8873 return 0;
8874 }
8875
8877 bool HasMuzzle()
8878 {
8879 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
8880 return true;
8881
8882 return false;
8883 }
8884
8886 int GetMuzzleID()
8887 {
8888 if (!m_WeaponTypeToID)
8889 m_WeaponTypeToID = new map<string, int>;
8890
8891 if (m_WeaponTypeToID.Contains(GetType()))
8892 {
8893 return m_WeaponTypeToID.Get(GetType());
8894 }
8895 else
8896 {
8897 // Register new weapon ID
8899 }
8900
8902 }
8903
8910 {
8911 return -1;
8912 }
8913
8914
8915
8916 // -------------------------------------------------------------------------
8917 void ~ItemBase()
8918 {
8919 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
8920 {
8921 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8922 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8923
8924 if (r_index >= 0)
8925 {
8926 InventoryLocation r_il = new InventoryLocation;
8927 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8928
8929 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8930 int r_type = r_il.GetType();
8931 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8932 {
8933 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8934 }
8935 else if (r_type == InventoryLocationType.ATTACHMENT)
8936 {
8937 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8938 }
8939
8940 }
8941
8942 player.GetHumanInventory().ClearUserReservedLocation(this);
8943 }
8944
8945 if (m_LockingSound)
8946 SEffectManager.DestroyEffect(m_LockingSound);
8947 }
8948
8949
8950
8951 // -------------------------------------------------------------------------
8952 static int GetDebugActionsMask()
8953 {
8954 return ItemBase.m_DebugActionsMask;
8955 }
8956
8957 static bool HasDebugActionsMask(int mask)
8958 {
8959 return ItemBase.m_DebugActionsMask & mask;
8960 }
8961
8962 static void SetDebugActionsMask(int mask)
8963 {
8964 ItemBase.m_DebugActionsMask = mask;
8965 }
8966
8967 static void AddDebugActionsMask(int mask)
8968 {
8969 ItemBase.m_DebugActionsMask |= mask;
8970 }
8971
8972 static void RemoveDebugActionsMask(int mask)
8973 {
8974 ItemBase.m_DebugActionsMask &= ~mask;
8975 }
8976
8977 static void ToggleDebugActionsMask(int mask)
8978 {
8979 if (HasDebugActionsMask(mask))
8980 {
8982 }
8983 else
8984 {
8985 AddDebugActionsMask(mask);
8986 }
8987 }
8988
8989 // -------------------------------------------------------------------------
8990 void SetCEBasedQuantity()
8991 {
8992 if (GetEconomyProfile())
8993 {
8994 float q_max = GetEconomyProfile().GetQuantityMax();
8995 if (q_max > 0)
8996 {
8997 float q_min = GetEconomyProfile().GetQuantityMin();
8998 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
8999
9000 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9001 {
9002 ComponentEnergyManager comp = GetCompEM();
9003 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
9004 {
9005 comp.SetEnergy0To1(quantity_randomized);
9006 }
9007 }
9008 else if (HasQuantity())
9009 {
9010 SetQuantityNormalized(quantity_randomized, false);
9011 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9012 }
9013
9014 }
9015 }
9016 }
9017
9019 void LockToParent()
9020 {
9021 EntityAI parent = GetHierarchyParent();
9022
9023 if (parent)
9024 {
9025 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9026 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9027 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9028 }
9029 }
9030
9032 void UnlockFromParent()
9033 {
9034 EntityAI parent = GetHierarchyParent();
9035
9036 if (parent)
9037 {
9038 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9039 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9040 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9041 }
9042 }
9043
9044 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9045 {
9046 /*
9047 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9048 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
9049 */
9050 ItemBase item2 = ItemBase.Cast(entity2);
9051
9052 if (g_Game.IsClient())
9053 {
9054 if (ScriptInputUserData.CanStoreInputUserData())
9055 {
9056 ScriptInputUserData ctx = new ScriptInputUserData;
9058 ctx.Write(-1);
9059 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9060 ctx.Write(i1);
9061 ctx.Write(item2);
9062 ctx.Write(use_stack_max);
9063 ctx.Write(-1);
9064 ctx.Send();
9065
9066 if (IsCombineAll(item2, use_stack_max))
9067 {
9068 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9069 }
9070 }
9071 }
9072 else if (!g_Game.IsMultiplayer())
9073 {
9074 CombineItems(item2, use_stack_max);
9075 }
9076 }
9077
9078 bool IsLiquidPresent()
9079 {
9080 return (GetLiquidType() != 0 && HasQuantity());
9081 }
9082
9083 bool IsLiquidContainer()
9084 {
9085 return m_LiquidContainerMask != 0;
9086 }
9087
9089 {
9090 return m_LiquidContainerMask;
9091 }
9092
9093 bool IsBloodContainer()
9094 {
9095 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9096 return false;
9097 }
9098
9099 bool IsNVG()
9100 {
9101 return false;
9102 }
9103
9106 bool IsExplosive()
9107 {
9108 return false;
9109 }
9110
9112 {
9113 return "";
9114 }
9115
9117
9118 bool IsLightSource()
9119 {
9120 return false;
9121 }
9122
9124 {
9125 return true;
9126 }
9127
9128 //--- ACTION CONDITIONS
9129 //direction
9130 bool IsFacingPlayer(PlayerBase player, string selection)
9131 {
9132 return true;
9133 }
9134
9135 bool IsPlayerInside(PlayerBase player, string selection)
9136 {
9137 return true;
9138 }
9139
9140 override bool CanObstruct()
9141 {
9142 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9143 return !player || !IsPlayerInside(player, "");
9144 }
9145
9146 override bool IsBeingPlaced()
9147 {
9148 return m_IsBeingPlaced;
9149 }
9150
9151 void SetIsBeingPlaced(bool is_being_placed)
9152 {
9153 m_IsBeingPlaced = is_being_placed;
9154 if (!is_being_placed)
9156 SetSynchDirty();
9157 }
9158
9159 //server-side
9160 void OnEndPlacement() {}
9161
9162 override bool IsHologram()
9163 {
9164 return m_IsHologram;
9165 }
9166
9167 bool CanBeDigged()
9168 {
9169 return m_CanBeDigged;
9170 }
9171
9173 {
9174 return 1;
9175 }
9176
9177 bool CanMakeGardenplot()
9178 {
9179 return false;
9180 }
9181
9182 void SetIsHologram(bool is_hologram)
9183 {
9184 m_IsHologram = is_hologram;
9185 SetSynchDirty();
9186 }
9187 /*
9188 protected float GetNutritionalEnergy()
9189 {
9190 Edible_Base edible = Edible_Base.Cast(this);
9191 return edible.GetFoodEnergy();
9192 }
9193
9194 protected float GetNutritionalWaterContent()
9195 {
9196 Edible_Base edible = Edible_Base.Cast(this);
9197 return edible.GetFoodWater();
9198 }
9199
9200 protected float GetNutritionalIndex()
9201 {
9202 Edible_Base edible = Edible_Base.Cast(this);
9203 return edible.GetFoodNutritionalIndex();
9204 }
9205
9206 protected float GetNutritionalFullnessIndex()
9207 {
9208 Edible_Base edible = Edible_Base.Cast(this);
9209 return edible.GetFoodTotalVolume();
9210 }
9211
9212 protected float GetNutritionalToxicity()
9213 {
9214 Edible_Base edible = Edible_Base.Cast(this);
9215 return edible.GetFoodToxicity();
9216
9217 }
9218 */
9219
9220
9221 // -------------------------------------------------------------------------
9222 override void OnMovedInsideCargo(EntityAI container)
9223 {
9224 super.OnMovedInsideCargo(container);
9225
9226 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9227 }
9228
9229 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9230 {
9231 super.EEItemLocationChanged(oldLoc, newLoc);
9232
9233 PlayerBase newPlayer = null;
9234 PlayerBase oldPlayer = null;
9235
9236 if (newLoc.GetParent())
9237 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9238
9239 if (oldLoc.GetParent())
9240 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9241
9242 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
9243 {
9244 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
9245
9246 if (rIndex >= 0)
9247 {
9248 InventoryLocation rIl = new InventoryLocation;
9249 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
9250
9251 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
9252 int rType = rIl.GetType();
9253 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
9254 {
9255 rIl.GetParent().GetOnReleaseLock().Invoke(this);
9256 }
9257 else if (rType == InventoryLocationType.ATTACHMENT)
9258 {
9259 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
9260 }
9261
9262 }
9263 }
9264
9265 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
9266 {
9267 if (newPlayer)
9268 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
9269
9270 if (newPlayer == oldPlayer)
9271 {
9272 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9273 {
9274 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9275 {
9276 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9277 {
9278 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9279 }
9280 }
9281 else
9282 {
9283 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9284 }
9285 }
9286
9287 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9288 {
9289 int type = oldLoc.GetType();
9290 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9291 {
9292 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9293 }
9294 else if (type == InventoryLocationType.ATTACHMENT)
9295 {
9296 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9297 }
9298 }
9299 if (!m_OldLocation)
9300 {
9301 m_OldLocation = new InventoryLocation;
9302 }
9303 m_OldLocation.Copy(oldLoc);
9304 }
9305 else
9306 {
9307 if (m_OldLocation)
9308 {
9309 m_OldLocation.Reset();
9310 }
9311 }
9312
9313 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
9314 }
9315 else
9316 {
9317 if (newPlayer)
9318 {
9319 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9320 if (resIndex >= 0)
9321 {
9322 InventoryLocation il = new InventoryLocation;
9323 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
9324 ItemBase it = ItemBase.Cast(il.GetItem());
9325 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
9326 int rel_type = il.GetType();
9327 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9328 {
9329 il.GetParent().GetOnReleaseLock().Invoke(it);
9330 }
9331 else if (rel_type == InventoryLocationType.ATTACHMENT)
9332 {
9333 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9334 }
9335 //it.GetOnReleaseLock().Invoke(it);
9336 }
9337 }
9338 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9339 {
9340 //ThrowPhysically(oldPlayer, vector.Zero);
9341 m_ThrowItemOnDrop = false;
9342 }
9343
9344 if (m_OldLocation)
9345 {
9346 m_OldLocation.Reset();
9347 }
9348 }
9349
9350 if (oldLoc.GetType() == InventoryLocationType.TEMP)
9351 {
9352 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
9353 }
9354
9355 if (newLoc.GetType() == InventoryLocationType.TEMP)
9356 {
9357 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
9358 }
9359 }
9360
9361 override void EOnContact(IEntity other, Contact extra)
9362 {
9364 {
9365 int liquidType = -1;
9366 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9367 if (impactSpeed > 0.0)
9368 {
9369 m_ImpactSpeed = impactSpeed;
9370 #ifndef SERVER
9371 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9372 #else
9373 m_WantPlayImpactSound = true;
9374 SetSynchDirty();
9375 #endif
9376 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9377 }
9378 }
9379
9380 #ifdef SERVER
9381 if (GetCompEM() && GetCompEM().IsPlugged())
9382 {
9383 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9384 GetCompEM().UnplugThis();
9385 }
9386 #endif
9387 }
9388
9389 void RefreshPhysics();
9390
9391 override void OnCreatePhysics()
9392 {
9394 }
9395
9396 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9397 {
9398
9399 }
9400 // -------------------------------------------------------------------------
9401 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9402 {
9403 super.OnItemLocationChanged(old_owner, new_owner);
9404
9405 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9406 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9407
9408 if (!relatedPlayer && playerNew)
9409 relatedPlayer = playerNew;
9410
9411 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9412 {
9413 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9414 if (actionMgr)
9415 {
9416 ActionBase currentAction = actionMgr.GetRunningAction();
9417 if (currentAction)
9418 currentAction.OnItemLocationChanged(this);
9419 }
9420 }
9421
9422 Man ownerPlayerOld = null;
9423 Man ownerPlayerNew = null;
9424
9425 if (old_owner)
9426 {
9427 if (old_owner.IsMan())
9428 {
9429 ownerPlayerOld = Man.Cast(old_owner);
9430 }
9431 else
9432 {
9433 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9434 }
9435 }
9436 else
9437 {
9438 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9439 {
9440 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9441
9442 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9443 {
9444 GetCompEM().UnplugThis();
9445 }
9446 }
9447 }
9448
9449 if (new_owner)
9450 {
9451 if (new_owner.IsMan())
9452 {
9453 ownerPlayerNew = Man.Cast(new_owner);
9454 }
9455 else
9456 {
9457 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
9458 }
9459 }
9460
9461 if (ownerPlayerOld != ownerPlayerNew)
9462 {
9463 if (ownerPlayerOld)
9464 {
9465 array<EntityAI> subItemsExit = new array<EntityAI>;
9466 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
9467 for (int i = 0; i < subItemsExit.Count(); i++)
9468 {
9469 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
9470 itemExit.OnInventoryExit(ownerPlayerOld);
9471 }
9472 }
9473
9474 if (ownerPlayerNew)
9475 {
9476 array<EntityAI> subItemsEnter = new array<EntityAI>;
9477 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
9478 for (int j = 0; j < subItemsEnter.Count(); j++)
9479 {
9480 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
9481 itemEnter.OnInventoryEnter(ownerPlayerNew);
9482 }
9483 }
9484 }
9485 else if (ownerPlayerNew != null)
9486 {
9487 PlayerBase nplayer;
9488 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
9489 {
9490 array<EntityAI> subItemsUpdate = new array<EntityAI>;
9491 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
9492 for (int k = 0; k < subItemsUpdate.Count(); k++)
9493 {
9494 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
9495 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
9496 }
9497 }
9498 }
9499
9500 if (old_owner)
9501 old_owner.OnChildItemRemoved(this);
9502 if (new_owner)
9503 new_owner.OnChildItemReceived(this);
9504 }
9505
9506 // -------------------------------------------------------------------------------
9507 override void EEDelete(EntityAI parent)
9508 {
9509 super.EEDelete(parent);
9510 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
9511 if (player)
9512 {
9513 OnInventoryExit(player);
9514
9515 if (player.IsAlive())
9516 {
9517 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9518 if (r_index >= 0)
9519 {
9520 InventoryLocation r_il = new InventoryLocation;
9521 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9522
9523 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9524 int r_type = r_il.GetType();
9525 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9526 {
9527 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9528 }
9529 else if (r_type == InventoryLocationType.ATTACHMENT)
9530 {
9531 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9532 }
9533
9534 }
9535
9536 player.RemoveQuickBarEntityShortcut(this);
9537 }
9538 }
9539 }
9540 // -------------------------------------------------------------------------------
9541 override void EEKilled(Object killer)
9542 {
9543 super.EEKilled(killer);
9544
9546 if (killer && killer.IsFireplace() && CanExplodeInFire())
9547 {
9548 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
9549 {
9550 if (IsMagazine())
9551 {
9552 if (Magazine.Cast(this).GetAmmoCount() > 0)
9553 {
9554 ExplodeAmmo();
9555 }
9556 }
9557 else
9558 {
9559 Explode(DamageType.EXPLOSION);
9560 }
9561 }
9562 }
9563 }
9564
9565 override void OnWasAttached(EntityAI parent, int slot_id)
9566 {
9567 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9568
9569 super.OnWasAttached(parent, slot_id);
9570
9571 if (HasQuantity())
9572 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9573
9574 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9575 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
9576 }
9577
9578 override void OnWasDetached(EntityAI parent, int slot_id)
9579 {
9580 super.OnWasDetached(parent, slot_id);
9581
9582 if (HasQuantity())
9583 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9584
9585 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9586 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
9587 }
9588
9589 override string ChangeIntoOnAttach(string slot)
9590 {
9591 int idx;
9592 TStringArray inventory_slots = new TStringArray;
9593 TStringArray attach_types = new TStringArray;
9594
9595 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9596 if (inventory_slots.Count() < 1) //is string
9597 {
9598 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
9599 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
9600 }
9601 else //is array
9602 {
9603 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
9604 }
9605
9606 idx = inventory_slots.Find(slot);
9607 if (idx < 0)
9608 return "";
9609
9610 return attach_types.Get(idx);
9611 }
9612
9613 override string ChangeIntoOnDetach()
9614 {
9615 int idx = -1;
9616 string slot;
9617
9618 TStringArray inventory_slots = new TStringArray;
9619 TStringArray detach_types = new TStringArray;
9620
9621 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9622 if (inventory_slots.Count() < 1) //is string
9623 {
9624 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
9625 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9626 }
9627 else //is array
9628 {
9629 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
9630 if (detach_types.Count() < 1)
9631 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9632 }
9633
9634 for (int i = 0; i < inventory_slots.Count(); i++)
9635 {
9636 slot = inventory_slots.Get(i);
9637 }
9638
9639 if (slot != "")
9640 {
9641 if (detach_types.Count() == 1)
9642 idx = 0;
9643 else
9644 idx = inventory_slots.Find(slot);
9645 }
9646 if (idx < 0)
9647 return "";
9648
9649 return detach_types.Get(idx);
9650 }
9651
9652 void ExplodeAmmo()
9653 {
9654 //timer
9655 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
9656
9657 //min/max time
9658 float min_time = 1;
9659 float max_time = 3;
9660 float delay = Math.RandomFloat(min_time, max_time);
9661
9662 explode_timer.Run(delay, this, "DoAmmoExplosion");
9663 }
9664
9665 void DoAmmoExplosion()
9666 {
9667 Magazine magazine = Magazine.Cast(this);
9668 int pop_sounds_count = 6;
9669 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
9670
9671 //play sound
9672 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
9673 string sound_name = pop_sounds[ sound_idx ];
9674 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
9675
9676 //remove ammo count
9677 magazine.ServerAddAmmoCount(-1);
9678
9679 //if condition then repeat -> ExplodeAmmo
9680 float min_temp_to_explode = 100; //min temperature for item to explode
9681
9682 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
9683 {
9684 ExplodeAmmo();
9685 }
9686 }
9687
9688 // -------------------------------------------------------------------------------
9689 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9690 {
9691 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
9692
9693 const int CHANCE_DAMAGE_CARGO = 4;
9694 const int CHANCE_DAMAGE_ATTACHMENT = 1;
9695 const int CHANCE_DAMAGE_NOTHING = 2;
9696
9697 if (IsClothing() || IsContainer() || IsItemTent())
9698 {
9699 float dmg = damageResult.GetDamage("","Health") * -0.5;
9700 int chances;
9701 int rnd;
9702
9703 if (GetInventory().GetCargo())
9704 {
9705 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9706 rnd = Math.RandomInt(0,chances);
9707
9708 if (rnd < CHANCE_DAMAGE_CARGO)
9709 {
9710 DamageItemInCargo(dmg);
9711 }
9712 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9713 {
9715 }
9716 }
9717 else
9718 {
9719 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9720 rnd = Math.RandomInt(0,chances);
9721
9722 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9723 {
9725 }
9726 }
9727 }
9728 }
9729
9730 bool DamageItemInCargo(float damage)
9731 {
9732 CargoBase cargo = GetInventory().GetCargo();
9733 if (cargo)
9734 {
9735 int item_count = cargo.GetItemCount();
9736 if (item_count > 0)
9737 {
9738 int random_pick = Math.RandomInt(0, item_count);
9739 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
9740 if (!item.IsExplosive())
9741 {
9742 item.AddHealth("","",damage);
9743 return true;
9744 }
9745 }
9746 }
9747 return false;
9748 }
9749
9750 bool DamageItemAttachments(float damage)
9751 {
9752 GameInventory inventory = GetInventory();
9753 int attachment_count = inventory.AttachmentCount();
9754 if (attachment_count > 0)
9755 {
9756 int random_pick = Math.RandomInt(0, attachment_count);
9757 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
9758 if (!attachment.IsExplosive())
9759 {
9760 attachment.AddHealth("","",damage);
9761 return true;
9762 }
9763 }
9764 return false;
9765 }
9766
9767 override bool IsSplitable()
9768 {
9769 return m_CanThisBeSplit;
9770 }
9771 //----------------
9772 override bool CanBeSplit()
9773 {
9774 if (IsSplitable() && (GetQuantity() > 1))
9775 return GetInventory().CanRemoveEntity();
9776
9777 return false;
9778 }
9779
9780 protected bool ShouldSplitQuantity(float quantity)
9781 {
9782 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
9783 if (!IsSplitable())
9784 return false;
9785
9786 // nothing to split?
9787 if (GetQuantity() <= 1)
9788 return false;
9789
9790 // check if we should re-use the item instead of creating a new copy?
9791 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
9792 int delta = GetQuantity() - quantity;
9793 if (delta == 0)
9794 return false;
9795
9796 // valid to split
9797 return true;
9798 }
9799
9800 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
9801 {
9802 if (g_Game.IsClient())
9803 {
9804 if (ScriptInputUserData.CanStoreInputUserData())
9805 {
9806 ScriptInputUserData ctx = new ScriptInputUserData;
9808 ctx.Write(1);
9809 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9810 ctx.Write(i1);
9811 ctx.Write(destination_entity);
9812 ctx.Write(true);
9813 ctx.Write(slot_id);
9814 ctx.Send();
9815 }
9816 }
9817 else if (!g_Game.IsMultiplayer())
9818 {
9819 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
9820 }
9821 }
9822
9823 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
9824 {
9825 float split_quantity_new;
9826 ItemBase new_item;
9827 float quantity = GetQuantity();
9828 float stack_max = GetTargetQuantityMax(slot_id);
9829 InventoryLocation loc = new InventoryLocation;
9830
9831 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9832 {
9833 if (stack_max <= GetQuantity())
9834 split_quantity_new = stack_max;
9835 else
9836 split_quantity_new = GetQuantity();
9837
9838 if (ShouldSplitQuantity(split_quantity_new))
9839 {
9840 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9841 if (new_item)
9842 {
9843 new_item.SetResultOfSplit(true);
9844 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9845 AddQuantity(-split_quantity_new, false, true);
9846 new_item.SetQuantity(split_quantity_new, false, true);
9847 }
9848 }
9849 }
9850 else if (destination_entity && slot_id == -1)
9851 {
9852 if (quantity > stack_max)
9853 split_quantity_new = stack_max;
9854 else
9855 split_quantity_new = quantity;
9856
9857 if (ShouldSplitQuantity(split_quantity_new))
9858 {
9859 GameInventory destinationInventory = destination_entity.GetInventory();
9860 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9861 {
9862 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9863 new_item = ItemBase.Cast(o);
9864 }
9865
9866 if (new_item)
9867 {
9868 new_item.SetResultOfSplit(true);
9869 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9870 AddQuantity(-split_quantity_new, false, true);
9871 new_item.SetQuantity(split_quantity_new, false, true);
9872 }
9873 }
9874 }
9875 else
9876 {
9877 if (stack_max != 0)
9878 {
9879 if (stack_max < GetQuantity())
9880 {
9881 split_quantity_new = GetQuantity() - stack_max;
9882 }
9883
9884 if (split_quantity_new == 0)
9885 {
9886 if (!g_Game.IsMultiplayer())
9887 player.PhysicalPredictiveDropItem(this);
9888 else
9889 player.ServerDropEntity(this);
9890 return;
9891 }
9892
9893 if (ShouldSplitQuantity(split_quantity_new))
9894 {
9895 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9896
9897 if (new_item)
9898 {
9899 new_item.SetResultOfSplit(true);
9900 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9901 SetQuantity(split_quantity_new, false, true);
9902 new_item.SetQuantity(stack_max, false, true);
9903 new_item.PlaceOnSurface();
9904 }
9905 }
9906 }
9907 }
9908 }
9909
9910 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
9911 {
9912 float split_quantity_new;
9913 ItemBase new_item;
9914 float quantity = GetQuantity();
9915 float stack_max = GetTargetQuantityMax(slot_id);
9916 InventoryLocation loc = new InventoryLocation;
9917
9918 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9919 {
9920 if (stack_max <= GetQuantity())
9921 split_quantity_new = stack_max;
9922 else
9923 split_quantity_new = GetQuantity();
9924
9925 if (ShouldSplitQuantity(split_quantity_new))
9926 {
9927 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9928 if (new_item)
9929 {
9930 new_item.SetResultOfSplit(true);
9931 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9932 AddQuantity(-split_quantity_new, false, true);
9933 new_item.SetQuantity(split_quantity_new, false, true);
9934 }
9935 }
9936 }
9937 else if (destination_entity && slot_id == -1)
9938 {
9939 if (quantity > stack_max)
9940 split_quantity_new = stack_max;
9941 else
9942 split_quantity_new = quantity;
9943
9944 if (ShouldSplitQuantity(split_quantity_new))
9945 {
9946 GameInventory destinationInventory = destination_entity.GetInventory();
9947 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9948 {
9949 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9950 new_item = ItemBase.Cast(o);
9951 }
9952
9953 if (new_item)
9954 {
9955 new_item.SetResultOfSplit(true);
9956 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9957 AddQuantity(-split_quantity_new, false, true);
9958 new_item.SetQuantity(split_quantity_new, false, true);
9959 }
9960 }
9961 }
9962 else
9963 {
9964 if (stack_max != 0)
9965 {
9966 if (stack_max < GetQuantity())
9967 {
9968 split_quantity_new = GetQuantity() - stack_max;
9969 }
9970
9971 if (ShouldSplitQuantity(split_quantity_new))
9972 {
9973 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9974
9975 if (new_item)
9976 {
9977 new_item.SetResultOfSplit(true);
9978 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9979 SetQuantity(split_quantity_new, false, true);
9980 new_item.SetQuantity(stack_max, false, true);
9981 new_item.PlaceOnSurface();
9982 }
9983 }
9984 }
9985 }
9986 }
9987
9988 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
9989 {
9990 if (g_Game.IsClient())
9991 {
9992 if (ScriptInputUserData.CanStoreInputUserData())
9993 {
9994 ScriptInputUserData ctx = new ScriptInputUserData;
9996 ctx.Write(4);
9997 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9998 ctx.Write(thiz);
9999 dst.WriteToContext(ctx);
10000 ctx.Send();
10001 }
10002 }
10003 else if (!g_Game.IsMultiplayer())
10004 {
10006 }
10007 }
10008
10009 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10010 {
10011 if (g_Game.IsClient())
10012 {
10013 if (ScriptInputUserData.CanStoreInputUserData())
10014 {
10015 ScriptInputUserData ctx = new ScriptInputUserData;
10017 ctx.Write(2);
10018 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10019 ctx.Write(dummy);
10020 ctx.Write(destination_entity);
10021 ctx.Write(true);
10022 ctx.Write(idx);
10023 ctx.Write(row);
10024 ctx.Write(col);
10025 ctx.Send();
10026 }
10027 }
10028 else if (!g_Game.IsMultiplayer())
10029 {
10030 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10031 }
10032 }
10033
10034 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10035 {
10037 }
10038
10039 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10040 {
10041 float quantity = GetQuantity();
10042 float split_quantity_new;
10043 ItemBase new_item;
10044 if (dst.IsValid())
10045 {
10046 int slot_id = dst.GetSlot();
10047 float stack_max = GetTargetQuantityMax(slot_id);
10048
10049 if (quantity > stack_max)
10050 split_quantity_new = stack_max;
10051 else
10052 split_quantity_new = quantity;
10053
10054 if (ShouldSplitQuantity(split_quantity_new))
10055 {
10056 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10057
10058 if (new_item)
10059 {
10060 new_item.SetResultOfSplit(true);
10061 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10062 AddQuantity(-split_quantity_new, false, true);
10063 new_item.SetQuantity(split_quantity_new, false, true);
10064 }
10065
10066 return new_item;
10067 }
10068 }
10069
10070 return null;
10071 }
10072
10073 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10074 {
10075 float quantity = GetQuantity();
10076 float split_quantity_new;
10077 ItemBase new_item;
10078 if (destination_entity)
10079 {
10080 float stackable = GetTargetQuantityMax();
10081 if (quantity > stackable)
10082 split_quantity_new = stackable;
10083 else
10084 split_quantity_new = quantity;
10085
10086 if (ShouldSplitQuantity(split_quantity_new))
10087 {
10088 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10089 if (new_item)
10090 {
10091 new_item.SetResultOfSplit(true);
10092 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10093 AddQuantity(-split_quantity_new, false, true);
10094 new_item.SetQuantity(split_quantity_new, false, true);
10095 }
10096 }
10097 }
10098 }
10099
10100 void SplitIntoStackMaxHandsClient(PlayerBase player)
10101 {
10102 if (g_Game.IsClient())
10103 {
10104 if (ScriptInputUserData.CanStoreInputUserData())
10105 {
10106 ScriptInputUserData ctx = new ScriptInputUserData;
10108 ctx.Write(3);
10109 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10110 ctx.Write(i1);
10111 ItemBase destination_entity = this;
10112 ctx.Write(destination_entity);
10113 ctx.Write(true);
10114 ctx.Write(0);
10115 ctx.Send();
10116 }
10117 }
10118 else if (!g_Game.IsMultiplayer())
10119 {
10120 SplitIntoStackMaxHands(player);
10121 }
10122 }
10123
10124 void SplitIntoStackMaxHands(PlayerBase player)
10125 {
10126 float quantity = GetQuantity();
10127 float split_quantity_new;
10128 ref ItemBase new_item;
10129 if (player)
10130 {
10131 float stackable = GetTargetQuantityMax();
10132 if (quantity > stackable)
10133 split_quantity_new = stackable;
10134 else
10135 split_quantity_new = quantity;
10136
10137 if (ShouldSplitQuantity(split_quantity_new))
10138 {
10139 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10140 new_item = ItemBase.Cast(in_hands);
10141 if (new_item)
10142 {
10143 new_item.SetResultOfSplit(true);
10144 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10145 AddQuantity(-split_quantity_new, false, true);
10146 new_item.SetQuantity(split_quantity_new, false, true);
10147 }
10148 }
10149 }
10150 }
10151
10152 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10153 {
10154 float quantity = GetQuantity();
10155 float split_quantity_new = Math.Floor(quantity * 0.5);
10156
10157 if (!ShouldSplitQuantity(split_quantity_new))
10158 return;
10159
10160 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10161
10162 if (new_item)
10163 {
10164 if (new_item.GetQuantityMax() < split_quantity_new)
10165 {
10166 split_quantity_new = new_item.GetQuantityMax();
10167 }
10168
10169 new_item.SetResultOfSplit(true);
10170 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10171
10172 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10173 {
10174 AddQuantity(-1, false, true);
10175 new_item.SetQuantity(1, false, true);
10176 }
10177 else
10178 {
10179 AddQuantity(-split_quantity_new, false, true);
10180 new_item.SetQuantity(split_quantity_new, false, true);
10181 }
10182 }
10183 }
10184
10185 void SplitItem(PlayerBase player)
10186 {
10187 float quantity = GetQuantity();
10188 float split_quantity_new = Math.Floor(quantity / 2);
10189
10190 if (!ShouldSplitQuantity(split_quantity_new))
10191 return;
10192
10193 InventoryLocation invloc = new InventoryLocation;
10194 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10195
10196 ItemBase new_item;
10197 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10198
10199 if (new_item)
10200 {
10201 if (new_item.GetQuantityMax() < split_quantity_new)
10202 {
10203 split_quantity_new = new_item.GetQuantityMax();
10204 }
10205 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10206 {
10207 AddQuantity(-1, false, true);
10208 new_item.SetQuantity(1, false, true);
10209 }
10210 else if (split_quantity_new > 1)
10211 {
10212 AddQuantity(-split_quantity_new, false, true);
10213 new_item.SetQuantity(split_quantity_new, false, true);
10214 }
10215 }
10216 }
10217
10219 void OnQuantityChanged(float delta)
10220 {
10221 SetWeightDirty();
10222 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10223
10224 if (parent)
10225 parent.OnAttachmentQuantityChangedEx(this, delta);
10226
10227 if (IsLiquidContainer())
10228 {
10229 if (GetQuantityNormalized() <= 0.0)
10230 {
10232 }
10233 else if (GetLiquidType() == LIQUID_NONE)
10234 {
10235 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10237 }
10238 }
10239 }
10240
10243 {
10244 // insert code here
10245 }
10246
10248 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10249 {
10251 }
10252
10253 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10254 {
10255 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10256
10257 if (g_Game.IsServer())
10258 {
10259 if (newLevel == GameConstants.STATE_RUINED)
10260 {
10262 EntityAI parent = GetHierarchyParent();
10263 if (parent && parent.IsFireplace())
10264 {
10265 CargoBase cargo = GetInventory().GetCargo();
10266 if (cargo)
10267 {
10268 for (int i = 0; i < cargo.GetItemCount(); ++i)
10269 {
10270 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10271 }
10272 }
10273 }
10274 }
10275
10276 if (IsResultOfSplit())
10277 {
10278 // reset the splitting result flag, return to normal item behavior
10279 SetResultOfSplit(false);
10280 return;
10281 }
10282
10283 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10284 {
10285 SetCleanness(0);//unclean the item upon damage dealt
10286 }
10287 }
10288 }
10289
10290 // just the split? TODO: verify
10291 override void OnRightClick()
10292 {
10293 super.OnRightClick();
10294
10295 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
10296 {
10297 if (g_Game.IsClient())
10298 {
10299 if (ScriptInputUserData.CanStoreInputUserData())
10300 {
10301 EntityAI root = GetHierarchyRoot();
10302 Man playerOwner = GetHierarchyRootPlayer();
10303 InventoryLocation dst = new InventoryLocation;
10304
10305 // 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
10306 if (!playerOwner && root && root == this)
10307 {
10309 }
10310 else
10311 {
10312 // 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
10313 GetInventory().GetCurrentInventoryLocation(dst);
10314 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10315 {
10316 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10317 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10318 {
10320 }
10321 else
10322 {
10323 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10324 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10325 this shouldnt cause issues within this scope*/
10326 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10327 {
10329 }
10330 else
10331 {
10332 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10333 }
10334 }
10335 }
10336 }
10337
10338 ScriptInputUserData ctx = new ScriptInputUserData;
10340 ctx.Write(4);
10341 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10342 ctx.Write(thiz);
10343 dst.WriteToContext(ctx);
10344 ctx.Write(true); // dummy
10345 ctx.Send();
10346 }
10347 }
10348 else if (!g_Game.IsMultiplayer())
10349 {
10350 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
10351 }
10352 }
10353 }
10354
10355 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10356 {
10357 if (root)
10358 {
10359 vector m4[4];
10360 root.GetTransform(m4);
10361 dst.SetGround(this, m4);
10362 }
10363 else
10364 {
10365 GetInventory().GetCurrentInventoryLocation(dst);
10366 }
10367 }
10368
10369 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10370 {
10371 //TODO: delete check zero quantity check after fix double posts hands fsm events
10372 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10373 return false;
10374
10375 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10376 return false;
10377
10378 //can_this_be_combined = ConfigGetBool("canBeSplit");
10380 return false;
10381
10382
10383 Magazine mag = Magazine.Cast(this);
10384 if (mag)
10385 {
10386 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10387 return false;
10388
10389 if (stack_max_limit)
10390 {
10391 Magazine other_mag = Magazine.Cast(other_item);
10392 if (other_item)
10393 {
10394 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10395 return false;
10396 }
10397
10398 }
10399 }
10400 else
10401 {
10402 //TODO: delete check zero quantity check after fix double posts hands fsm events
10403 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10404 return false;
10405
10406 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10407 return false;
10408 }
10409
10410 PlayerBase player = null;
10411 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10412 {
10413 if (player.GetInventory().HasAttachment(this))
10414 return false;
10415
10416 if (player.IsItemsToDelete())
10417 return false;
10418 }
10419
10420 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10421 return false;
10422
10423 int slotID;
10424 string slotName;
10425 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10426 return false;
10427
10428 return true;
10429 }
10430
10431 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10432 {
10433 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10434 }
10435
10436 bool IsResultOfSplit()
10437 {
10438 return m_IsResultOfSplit;
10439 }
10440
10441 void SetResultOfSplit(bool value)
10442 {
10443 m_IsResultOfSplit = value;
10444 }
10445
10446 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
10447 {
10448 return ComputeQuantityUsedEx(other_item, use_stack_max);
10449 }
10450
10451 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
10452 {
10453 float other_item_quantity = other_item.GetQuantity();
10454 float this_free_space;
10455
10456 float stack_max = GetQuantityMax();
10457
10458 this_free_space = stack_max - GetQuantity();
10459
10460 if (other_item_quantity > this_free_space)
10461 {
10462 return this_free_space;
10463 }
10464 else
10465 {
10466 return other_item_quantity;
10467 }
10468 }
10469
10470 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
10471 {
10472 CombineItems(ItemBase.Cast(entity2),use_stack_max);
10473 }
10474
10475 void CombineItems(ItemBase other_item, bool use_stack_max = true)
10476 {
10477 if (!CanBeCombined(other_item, false))
10478 return;
10479
10480 if (!IsMagazine() && other_item)
10481 {
10482 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
10483 if (quantity_used != 0)
10484 {
10485 float hp1 = GetHealth01("","");
10486 float hp2 = other_item.GetHealth01("","");
10487 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
10488 hpResult = hpResult / (GetQuantity() + quantity_used);
10489
10490 hpResult *= GetMaxHealth();
10491 Math.Round(hpResult);
10492 SetHealth("", "Health", hpResult);
10493
10494 AddQuantity(quantity_used);
10495 other_item.AddQuantity(-quantity_used);
10496 }
10497 }
10498 OnCombine(other_item);
10499 }
10500
10501 void OnCombine(ItemBase other_item)
10502 {
10503 #ifdef SERVER
10504 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
10505 GetHierarchyParent().IncreaseLifetimeUp();
10506 #endif
10507 };
10508
10509 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
10510 {
10511 PlayerBase p = PlayerBase.Cast(player);
10512
10513 array<int> recipesIds = p.m_Recipes;
10514 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10515 if (moduleRecipesManager)
10516 {
10517 EntityAI itemInHands = player.GetEntityInHands();
10518 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
10519 }
10520
10521 for (int i = 0;i < recipesIds.Count(); i++)
10522 {
10523 int key = recipesIds.Get(i);
10524 string recipeName = moduleRecipesManager.GetRecipeName(key);
10525 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
10526 }
10527 }
10528
10529 // -------------------------------------------------------------------------
10530 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
10531 {
10532 super.GetDebugActions(outputList);
10533
10534 //quantity
10535 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
10536 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
10537 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
10538 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
10539 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10540
10541 //health
10542 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
10543 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
10544 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
10545 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10546 //temperature
10547 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
10548 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
10549 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
10550 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10551
10552 //wet
10553 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
10554 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
10555 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10556
10557 //liquidtype
10558 if (IsLiquidContainer())
10559 {
10560 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
10561 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
10562 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10563 }
10564
10565 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
10566 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10567
10568 // watch
10569 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
10570 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
10571 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10572
10573 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
10574
10575 InventoryLocation loc = new InventoryLocation();
10576 GetInventory().GetCurrentInventoryLocation(loc);
10577 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
10578 {
10579 if (Gizmo_IsSupported())
10580 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
10581 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
10582 }
10583
10584 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10585 }
10586
10587 // -------------------------------------------------------------------------
10588 // -------------------------------------------------------------------------
10589 // -------------------------------------------------------------------------
10590 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
10591 {
10592 super.OnAction(action_id, player, ctx);
10593
10594 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
10595 {
10596 switch (action_id)
10597 {
10598 case EActions.GIZMO_OBJECT:
10599 if (GetGizmoApi())
10600 GetGizmoApi().SelectObject(this);
10601 return true;
10602 case EActions.GIZMO_PHYSICS:
10603 if (GetGizmoApi())
10604 GetGizmoApi().SelectPhysics(GetPhysics());
10605 return true;
10606 }
10607 }
10608
10609 if (g_Game.IsServer())
10610 {
10611 switch (action_id)
10612 {
10613 case EActions.DELETE:
10614 Delete();
10615 return true;
10616 }
10617 }
10618
10619 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
10620 {
10621 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10622 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
10623 PlayerBase p = PlayerBase.Cast(player);
10624 if (EActions.RECIPES_RANGE_START < 1000)
10625 {
10626 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
10627 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
10628 }
10629 }
10630 #ifndef SERVER
10631 else if (action_id == EActions.WATCH_PLAYER)
10632 {
10633 PluginDeveloper.SetDeveloperItemClientEx(player);
10634 }
10635 #endif
10636 if (g_Game.IsServer())
10637 {
10638 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
10639 {
10640 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
10641 OnDebugButtonPressServer(id + 1);
10642 }
10643
10644 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
10645 {
10646 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
10647 InsertAgent(agent_id,100);
10648 }
10649
10650 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
10651 {
10652 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
10653 RemoveAgent(agent_id2);
10654 }
10655
10656 else if (action_id == EActions.ADD_QUANTITY)
10657 {
10658 if (IsMagazine())
10659 {
10660 Magazine mag = Magazine.Cast(this);
10661 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
10662 }
10663 else
10664 {
10665 AddQuantity(GetQuantityMax() * 0.2);
10666 }
10667
10668 if (m_EM)
10669 {
10670 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
10671 }
10672 //PrintVariables();
10673 }
10674
10675 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
10676 {
10677 if (IsMagazine())
10678 {
10679 Magazine mag2 = Magazine.Cast(this);
10680 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
10681 }
10682 else
10683 {
10684 AddQuantity(- GetQuantityMax() * 0.2);
10685 }
10686 if (m_EM)
10687 {
10688 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
10689 }
10690 //PrintVariables();
10691 }
10692
10693 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
10694 {
10695 SetQuantity(0);
10696
10697 if (m_EM)
10698 {
10699 m_EM.SetEnergy(0);
10700 }
10701 }
10702
10703 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
10704 {
10706
10707 if (m_EM)
10708 {
10709 m_EM.SetEnergy(m_EM.GetEnergyMax());
10710 }
10711 }
10712
10713 else if (action_id == EActions.ADD_HEALTH)
10714 {
10715 AddHealth("","",GetMaxHealth("","Health")/5);
10716 }
10717 else if (action_id == EActions.REMOVE_HEALTH)
10718 {
10719 AddHealth("","",-GetMaxHealth("","Health")/5);
10720 }
10721 else if (action_id == EActions.DESTROY_HEALTH)
10722 {
10723 SetHealth01("","",0);
10724 }
10725 else if (action_id == EActions.WATCH_ITEM)
10726 {
10728 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10729 #ifdef DEVELOPER
10730 SetDebugDeveloper_item(this);
10731 #endif
10732 }
10733
10734 else if (action_id == EActions.ADD_TEMPERATURE)
10735 {
10736 AddTemperature(20);
10737 //PrintVariables();
10738 }
10739
10740 else if (action_id == EActions.REMOVE_TEMPERATURE)
10741 {
10742 AddTemperature(-20);
10743 //PrintVariables();
10744 }
10745
10746 else if (action_id == EActions.FLIP_FROZEN)
10747 {
10748 SetFrozen(!GetIsFrozen());
10749 //PrintVariables();
10750 }
10751
10752 else if (action_id == EActions.ADD_WETNESS)
10753 {
10754 AddWet(GetWetMax()/5);
10755 //PrintVariables();
10756 }
10757
10758 else if (action_id == EActions.REMOVE_WETNESS)
10759 {
10760 AddWet(-GetWetMax()/5);
10761 //PrintVariables();
10762 }
10763
10764 else if (action_id == EActions.LIQUIDTYPE_UP)
10765 {
10766 int curr_type = GetLiquidType();
10767 SetLiquidType(curr_type * 2);
10768 //AddWet(1);
10769 //PrintVariables();
10770 }
10771
10772 else if (action_id == EActions.LIQUIDTYPE_DOWN)
10773 {
10774 int curr_type2 = GetLiquidType();
10775 SetLiquidType(curr_type2 / 2);
10776 }
10777
10778 else if (action_id == EActions.MAKE_SPECIAL)
10779 {
10780 auto debugParams = DebugSpawnParams.WithPlayer(player);
10781 OnDebugSpawnEx(debugParams);
10782 }
10783
10784 }
10785
10786
10787 return false;
10788 }
10789
10790 // -------------------------------------------------------------------------
10791
10792
10795 void OnActivatedByTripWire();
10796
10798 void OnActivatedByItem(notnull ItemBase item);
10799
10800 //----------------------------------------------------------------
10801 //returns true if item is able to explode when put in fire
10802 bool CanExplodeInFire()
10803 {
10804 return false;
10805 }
10806
10807 //----------------------------------------------------------------
10808 bool CanEat()
10809 {
10810 return true;
10811 }
10812
10813 //----------------------------------------------------------------
10814 override bool IsIgnoredByConstruction()
10815 {
10816 return true;
10817 }
10818
10819 //----------------------------------------------------------------
10820 //has FoodStages in config?
10821 bool HasFoodStage()
10822 {
10823 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
10824 return g_Game.ConfigIsExisting(config_path);
10825 }
10826
10828 FoodStage GetFoodStage()
10829 {
10830 return null;
10831 }
10832
10833 bool CanBeCooked()
10834 {
10835 return false;
10836 }
10837
10838 bool CanBeCookedOnStick()
10839 {
10840 return false;
10841 }
10842
10844 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
10846
10847 //----------------------------------------------------------------
10848 bool CanRepair(ItemBase item_repair_kit)
10849 {
10850 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10851 return module_repairing.CanRepair(this, item_repair_kit);
10852 }
10853
10854 //----------------------------------------------------------------
10855 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
10856 {
10857 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10858 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
10859 }
10860
10861 //----------------------------------------------------------------
10862 int GetItemSize()
10863 {
10864 /*
10865 vector v_size = this.ConfigGetVector("itemSize");
10866 int v_size_x = v_size[0];
10867 int v_size_y = v_size[1];
10868 int size = v_size_x * v_size_y;
10869 return size;
10870 */
10871
10872 return 1;
10873 }
10874
10875 //----------------------------------------------------------------
10876 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10877 bool CanBeMovedOverride()
10878 {
10879 return m_CanBeMovedOverride;
10880 }
10881
10882 //----------------------------------------------------------------
10883 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10884 void SetCanBeMovedOverride(bool setting)
10885 {
10886 m_CanBeMovedOverride = setting;
10887 }
10888
10889 //----------------------------------------------------------------
10897 void MessageToOwnerStatus(string text)
10898 {
10899 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10900
10901 if (player)
10902 {
10903 player.MessageStatus(text);
10904 }
10905 }
10906
10907 //----------------------------------------------------------------
10915 void MessageToOwnerAction(string text)
10916 {
10917 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10918
10919 if (player)
10920 {
10921 player.MessageAction(text);
10922 }
10923 }
10924
10925 //----------------------------------------------------------------
10933 void MessageToOwnerFriendly(string text)
10934 {
10935 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10936
10937 if (player)
10938 {
10939 player.MessageFriendly(text);
10940 }
10941 }
10942
10943 //----------------------------------------------------------------
10951 void MessageToOwnerImportant(string text)
10952 {
10953 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10954
10955 if (player)
10956 {
10957 player.MessageImportant(text);
10958 }
10959 }
10960
10961 override bool IsItemBase()
10962 {
10963 return true;
10964 }
10965
10966 // Checks if item is of questioned kind
10967 override bool KindOf(string tag)
10968 {
10969 bool found = false;
10970 string item_name = this.GetType();
10971 ref TStringArray item_tag_array = new TStringArray;
10972 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
10973
10974 int array_size = item_tag_array.Count();
10975 for (int i = 0; i < array_size; i++)
10976 {
10977 if (item_tag_array.Get(i) == tag)
10978 {
10979 found = true;
10980 break;
10981 }
10982 }
10983 return found;
10984 }
10985
10986
10987 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
10988 {
10989 //Debug.Log("OnRPC called");
10990 super.OnRPC(sender, rpc_type,ctx);
10991
10992 //Play soundset for attachment locking (ActionLockAttachment.c)
10993 switch (rpc_type)
10994 {
10995 #ifndef SERVER
10996 case ERPCs.RPC_SOUND_LOCK_ATTACH:
10997 Param2<bool, string> p = new Param2<bool, string>(false, "");
10998
10999 if (!ctx.Read(p))
11000 return;
11001
11002 bool play = p.param1;
11003 string soundSet = p.param2;
11004
11005 if (play)
11006 {
11007 if (m_LockingSound)
11008 {
11010 {
11011 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11012 }
11013 }
11014 else
11015 {
11016 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11017 }
11018 }
11019 else
11020 {
11021 SEffectManager.DestroyEffect(m_LockingSound);
11022 }
11023
11024 break;
11025 #endif
11026
11027 }
11028
11029 if (GetWrittenNoteData())
11030 {
11031 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11032 }
11033 }
11034
11035 //-----------------------------
11036 // VARIABLE MANIPULATION SYSTEM
11037 //-----------------------------
11038 int NameToID(string name)
11039 {
11040 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11041 return plugin.GetID(name);
11042 }
11043
11044 string IDToName(int id)
11045 {
11046 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11047 return plugin.GetName(id);
11048 }
11049
11051 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11052 {
11053 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11054 //read the flags
11055 int varFlags;
11056 if (!ctx.Read(varFlags))
11057 return;
11058
11059 if (varFlags & ItemVariableFlags.FLOAT)
11060 {
11061 ReadVarsFromCTX(ctx);
11062 }
11063 }
11064
11065 override void SerializeNumericalVars(array<float> floats_out)
11066 {
11067 //some variables handled on EntityAI level already!
11068 super.SerializeNumericalVars(floats_out);
11069
11070 // the order of serialization must be the same as the order of de-serialization
11071 //--------------------------------------------
11072 if (IsVariableSet(VARIABLE_QUANTITY))
11073 {
11074 floats_out.Insert(m_VarQuantity);
11075 }
11076 //--------------------------------------------
11077 if (IsVariableSet(VARIABLE_WET))
11078 {
11079 floats_out.Insert(m_VarWet);
11080 }
11081 //--------------------------------------------
11082 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11083 {
11084 floats_out.Insert(m_VarLiquidType);
11085 }
11086 //--------------------------------------------
11087 if (IsVariableSet(VARIABLE_COLOR))
11088 {
11089 floats_out.Insert(m_ColorComponentR);
11090 floats_out.Insert(m_ColorComponentG);
11091 floats_out.Insert(m_ColorComponentB);
11092 floats_out.Insert(m_ColorComponentA);
11093 }
11094 //--------------------------------------------
11095 if (IsVariableSet(VARIABLE_CLEANNESS))
11096 {
11097 floats_out.Insert(m_Cleanness);
11098 }
11099 }
11100
11101 override void DeSerializeNumericalVars(array<float> floats)
11102 {
11103 //some variables handled on EntityAI level already!
11104 super.DeSerializeNumericalVars(floats);
11105
11106 // the order of serialization must be the same as the order of de-serialization
11107 int index = 0;
11108 int mask = Math.Round(floats.Get(index));
11109
11110 index++;
11111 //--------------------------------------------
11112 if (mask & VARIABLE_QUANTITY)
11113 {
11114 if (m_IsStoreLoad)
11115 {
11116 SetStoreLoadedQuantity(floats.Get(index));
11117 }
11118 else
11119 {
11120 float quantity = floats.Get(index);
11121 SetQuantity(quantity, true, false, false, false);
11122 }
11123 index++;
11124 }
11125 //--------------------------------------------
11126 if (mask & VARIABLE_WET)
11127 {
11128 float wet = floats.Get(index);
11129 SetWet(wet);
11130 index++;
11131 }
11132 //--------------------------------------------
11133 if (mask & VARIABLE_LIQUIDTYPE)
11134 {
11135 int liquidtype = Math.Round(floats.Get(index));
11136 SetLiquidType(liquidtype);
11137 index++;
11138 }
11139 //--------------------------------------------
11140 if (mask & VARIABLE_COLOR)
11141 {
11142 m_ColorComponentR = Math.Round(floats.Get(index));
11143 index++;
11144 m_ColorComponentG = Math.Round(floats.Get(index));
11145 index++;
11146 m_ColorComponentB = Math.Round(floats.Get(index));
11147 index++;
11148 m_ColorComponentA = Math.Round(floats.Get(index));
11149 index++;
11150 }
11151 //--------------------------------------------
11152 if (mask & VARIABLE_CLEANNESS)
11153 {
11154 int cleanness = Math.Round(floats.Get(index));
11155 SetCleanness(cleanness);
11156 index++;
11157 }
11158 }
11159
11160 override void WriteVarsToCTX(ParamsWriteContext ctx)
11161 {
11162 super.WriteVarsToCTX(ctx);
11163
11164 //--------------------------------------------
11165 if (IsVariableSet(VARIABLE_QUANTITY))
11166 {
11167 ctx.Write(GetQuantity());
11168 }
11169 //--------------------------------------------
11170 if (IsVariableSet(VARIABLE_WET))
11171 {
11172 ctx.Write(GetWet());
11173 }
11174 //--------------------------------------------
11175 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11176 {
11177 ctx.Write(GetLiquidType());
11178 }
11179 //--------------------------------------------
11180 if (IsVariableSet(VARIABLE_COLOR))
11181 {
11182 int r,g,b,a;
11183 GetColor(r,g,b,a);
11184 ctx.Write(r);
11185 ctx.Write(g);
11186 ctx.Write(b);
11187 ctx.Write(a);
11188 }
11189 //--------------------------------------------
11190 if (IsVariableSet(VARIABLE_CLEANNESS))
11191 {
11192 ctx.Write(GetCleanness());
11193 }
11194 }
11195
11196 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11197 {
11198 if (!super.ReadVarsFromCTX(ctx,version))
11199 return false;
11200
11201 int intValue;
11202 float value;
11203
11204 if (version < 140)
11205 {
11206 if (!ctx.Read(intValue))
11207 return false;
11208
11209 m_VariablesMask = intValue;
11210 }
11211
11212 if (m_VariablesMask & VARIABLE_QUANTITY)
11213 {
11214 if (!ctx.Read(value))
11215 return false;
11216
11217 if (IsStoreLoad())
11218 {
11220 }
11221 else
11222 {
11223 SetQuantity(value, true, false, false, false);
11224 }
11225 }
11226 //--------------------------------------------
11227 if (version < 140)
11228 {
11229 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11230 {
11231 if (!ctx.Read(value))
11232 return false;
11233 SetTemperatureDirect(value);
11234 }
11235 }
11236 //--------------------------------------------
11237 if (m_VariablesMask & VARIABLE_WET)
11238 {
11239 if (!ctx.Read(value))
11240 return false;
11241 SetWet(value);
11242 }
11243 //--------------------------------------------
11244 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11245 {
11246 if (!ctx.Read(intValue))
11247 return false;
11248 SetLiquidType(intValue);
11249 }
11250 //--------------------------------------------
11251 if (m_VariablesMask & VARIABLE_COLOR)
11252 {
11253 int r,g,b,a;
11254 if (!ctx.Read(r))
11255 return false;
11256 if (!ctx.Read(g))
11257 return false;
11258 if (!ctx.Read(b))
11259 return false;
11260 if (!ctx.Read(a))
11261 return false;
11262
11263 SetColor(r,g,b,a);
11264 }
11265 //--------------------------------------------
11266 if (m_VariablesMask & VARIABLE_CLEANNESS)
11267 {
11268 if (!ctx.Read(intValue))
11269 return false;
11270 SetCleanness(intValue);
11271 }
11272 //--------------------------------------------
11273 if (version >= 138 && version < 140)
11274 {
11275 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11276 {
11277 if (!ctx.Read(intValue))
11278 return false;
11279 SetFrozen(intValue);
11280 }
11281 }
11282
11283 return true;
11284 }
11285
11286 //----------------------------------------------------------------
11287 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11288 {
11289 m_IsStoreLoad = true;
11291 {
11292 m_FixDamageSystemInit = true;
11293 }
11294
11295 if (!super.OnStoreLoad(ctx, version))
11296 {
11297 m_IsStoreLoad = false;
11298 return false;
11299 }
11300
11301 if (version >= 114)
11302 {
11303 bool hasQuickBarIndexSaved;
11304
11305 if (!ctx.Read(hasQuickBarIndexSaved))
11306 {
11307 m_IsStoreLoad = false;
11308 return false;
11309 }
11310
11311 if (hasQuickBarIndexSaved)
11312 {
11313 int itmQBIndex;
11314
11315 //Load quickbar item bind
11316 if (!ctx.Read(itmQBIndex))
11317 {
11318 m_IsStoreLoad = false;
11319 return false;
11320 }
11321
11322 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11323 if (itmQBIndex != -1 && parentPlayer)
11324 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11325 }
11326 }
11327 else
11328 {
11329 // Backup of how it used to be
11330 PlayerBase player;
11331 int itemQBIndex;
11332 if (version == int.MAX)
11333 {
11334 if (!ctx.Read(itemQBIndex))
11335 {
11336 m_IsStoreLoad = false;
11337 return false;
11338 }
11339 }
11340 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11341 {
11342 //Load quickbar item bind
11343 if (!ctx.Read(itemQBIndex))
11344 {
11345 m_IsStoreLoad = false;
11346 return false;
11347 }
11348 if (itemQBIndex != -1 && player)
11349 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11350 }
11351 }
11352
11353 if (version < 140)
11354 {
11355 // variable management system
11356 if (!LoadVariables(ctx, version))
11357 {
11358 m_IsStoreLoad = false;
11359 return false;
11360 }
11361 }
11362
11363 //agent trasmission system
11364 if (!LoadAgents(ctx, version))
11365 {
11366 m_IsStoreLoad = false;
11367 return false;
11368 }
11369 if (version >= 132)
11370 {
11371 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11372 if (raib)
11373 {
11374 if (!raib.OnStoreLoad(ctx,version))
11375 {
11376 m_IsStoreLoad = false;
11377 return false;
11378 }
11379 }
11380 }
11381
11382 m_IsStoreLoad = false;
11383 return true;
11384 }
11385
11386 //----------------------------------------------------------------
11387
11388 override void OnStoreSave(ParamsWriteContext ctx)
11389 {
11390 super.OnStoreSave(ctx);
11391
11392 PlayerBase player;
11393 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11394 {
11395 ctx.Write(true); // Keep track of if we should actually read this in or not
11396 //Save quickbar item bind
11397 int itemQBIndex = -1;
11398 itemQBIndex = player.FindQuickBarEntityIndex(this);
11399 ctx.Write(itemQBIndex);
11400 }
11401 else
11402 {
11403 ctx.Write(false); // Keep track of if we should actually read this in or not
11404 }
11405
11406 SaveAgents(ctx);//agent trasmission system
11407
11408 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11409 if (raib)
11410 {
11411 raib.OnStoreSave(ctx);
11412 }
11413 }
11414 //----------------------------------------------------------------
11415
11416 override void AfterStoreLoad()
11417 {
11418 super.AfterStoreLoad();
11419
11421 {
11423 }
11424
11425 if (GetStoreLoadedQuantity() != float.LOWEST)
11426 {
11428 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
11429 }
11430 }
11431
11432 override void EEOnAfterLoad()
11433 {
11434 super.EEOnAfterLoad();
11435
11437 {
11438 m_FixDamageSystemInit = false;
11439 }
11440
11443 }
11444
11445 bool CanBeDisinfected()
11446 {
11447 return false;
11448 }
11449
11450
11451 //----------------------------------------------------------------
11452 override void OnVariablesSynchronized()
11453 {
11454 if (m_Initialized)
11455 {
11456 #ifdef PLATFORM_CONSOLE
11457 //bruteforce it is
11458 if (IsSplitable())
11459 {
11460 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
11461 if (menu)
11462 {
11463 menu.Refresh();
11464 }
11465 }
11466 #endif
11467 }
11468
11470 {
11471 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
11472 m_WantPlayImpactSound = false;
11473 }
11474
11476 {
11477 SetWeightDirty();
11479 }
11480 if (m_VarWet != m_VarWetPrev)
11481 {
11484 }
11485
11486 if (m_SoundSyncPlay != 0)
11487 {
11490
11491 m_SoundSyncPlay = 0;
11492 m_SoundSyncSlotID = -1;
11493 }
11494 if (m_SoundSyncStop != 0)
11495 {
11497 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
11498 m_SoundSyncStop = 0;
11499 }
11500
11501 super.OnVariablesSynchronized();
11502 }
11503
11504 //------------------------- Quantity
11505 //----------------------------------------------------------------
11507 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
11508 {
11509 if (!IsServerCheck(allow_client))
11510 return false;
11511
11512 if (!HasQuantity())
11513 return false;
11514
11515 float min = GetQuantityMin();
11516 float max = GetQuantityMax();
11517
11518 if (value <= (min + 0.001))
11519 value = min;
11520
11521 if (value == min)
11522 {
11523 if (destroy_config)
11524 {
11525 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
11526 if (dstr)
11527 {
11528 m_VarQuantity = Math.Clamp(value, min, max);
11529 this.Delete();
11530 return true;
11531 }
11532 }
11533 else if (destroy_forced)
11534 {
11535 m_VarQuantity = Math.Clamp(value, min, max);
11536 this.Delete();
11537 return true;
11538 }
11539 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
11540 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
11541 }
11542
11543 float delta = m_VarQuantity;
11544 m_VarQuantity = Math.Clamp(value, min, max);
11545
11546 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
11547 {
11548 EntityAI parent = GetHierarchyRoot();
11549 InventoryLocation iLoc = new InventoryLocation();
11550 GetInventory().GetCurrentInventoryLocation(iLoc);
11551 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
11552 {
11553 int iLocSlot = iLoc.GetSlot();
11554 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
11555 {
11556 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
11557 }
11558 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
11559 {
11560 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
11561 }
11562 }
11563 }
11564
11565 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
11566 {
11567 delta = m_VarQuantity - delta;
11568
11569 if (delta)
11570 OnQuantityChanged(delta);
11571 }
11572
11573 SetVariableMask(VARIABLE_QUANTITY);
11574
11575 return false;
11576 }
11577
11578 //----------------------------------------------------------------
11580 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
11581 {
11582 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
11583 }
11584 //----------------------------------------------------------------
11585 void SetQuantityMax()
11586 {
11587 float max = GetQuantityMax();
11588 SetQuantity(max);
11589 }
11590
11591 override void SetQuantityToMinimum()
11592 {
11593 float min = GetQuantityMin();
11594 SetQuantity(min);
11595 }
11596 //----------------------------------------------------------------
11598 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
11599 {
11600 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
11601 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
11602 SetQuantity(result, destroy_config, destroy_forced);
11603 }
11604
11605 //----------------------------------------------------------------
11607 override float GetQuantityNormalized()
11608 {
11609 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
11610 }
11611
11613 {
11614 return GetQuantityNormalized();
11615 }
11616
11617 /*void SetAmmoNormalized(float value)
11618 {
11619 float value_clamped = Math.Clamp(value, 0, 1);
11620 Magazine this_mag = Magazine.Cast(this);
11621 int max_rounds = this_mag.GetAmmoMax();
11622 int result = value * max_rounds;//can the rounded if higher precision is required
11623 this_mag.SetAmmoCount(result);
11624 }*/
11625 //----------------------------------------------------------------
11626 override int GetQuantityMax()
11627 {
11628 int slot = -1;
11629 GameInventory inventory = GetInventory();
11630 if (inventory)
11631 {
11632 InventoryLocation il = new InventoryLocation;
11633 inventory.GetCurrentInventoryLocation(il);
11634 slot = il.GetSlot();
11635 }
11636
11637 return GetTargetQuantityMax(slot);
11638 }
11639
11640 override int GetTargetQuantityMax(int attSlotID = -1)
11641 {
11642 float quantity_max = 0;
11643
11644 if (IsSplitable()) //only stackable/splitable items can check for stack size
11645 {
11646 if (attSlotID != -1)
11647 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
11648
11649 if (quantity_max <= 0)
11650 quantity_max = m_VarStackMax;
11651 }
11652
11653 if (quantity_max <= 0)
11654 quantity_max = m_VarQuantityMax;
11655
11656 return quantity_max;
11657 }
11658 //----------------------------------------------------------------
11659 override int GetQuantityMin()
11660 {
11661 return m_VarQuantityMin;
11662 }
11663 //----------------------------------------------------------------
11664 int GetQuantityInit()
11665 {
11666 return m_VarQuantityInit;
11667 }
11668
11669 //----------------------------------------------------------------
11670 override bool HasQuantity()
11671 {
11672 return !(GetQuantityMax() - GetQuantityMin() == 0);
11673 }
11674
11675 override float GetQuantity()
11676 {
11677 return m_VarQuantity;
11678 }
11679
11680 bool IsFullQuantity()
11681 {
11682 return GetQuantity() >= GetQuantityMax();
11683 }
11684
11685 //Calculates weight of single item without attachments and cargo
11686 override float GetSingleInventoryItemWeightEx()
11687 {
11688 //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
11689 float weightEx = GetWeightEx();//overall weight of the item
11690 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
11691 return weightEx - special;
11692 }
11693
11694 // Obsolete, use GetSingleInventoryItemWeightEx() instead
11696 {
11698 }
11699
11700 override protected float GetWeightSpecialized(bool forceRecalc = false)
11701 {
11702 if (IsSplitable()) //quantity determines size of the stack
11703 {
11704 #ifdef DEVELOPER
11705 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11706 {
11707 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
11708 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
11709 }
11710 #endif
11711
11712 return GetQuantity() * GetConfigWeightModified();
11713 }
11714 else if (HasEnergyManager())// items with energy manager
11715 {
11716 #ifdef DEVELOPER
11717 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11718 {
11719 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
11720 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
11721 }
11722 #endif
11723 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11724 }
11725 else//everything else
11726 {
11727 #ifdef DEVELOPER
11728 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11729 {
11730 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
11731 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
11732 }
11733 #endif
11734 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11735 }
11736 }
11737
11739 int GetNumberOfItems()
11740 {
11741 int item_count = 0;
11742 ItemBase item;
11743
11744 GameInventory inventory = GetInventory();
11745 CargoBase cargo = inventory.GetCargo();
11746 if (cargo != NULL)
11747 {
11748 item_count = cargo.GetItemCount();
11749 }
11750
11751 int nAttachments = inventory.AttachmentCount();
11752 for (int i = 0; i < nAttachments; ++i)
11753 {
11754 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
11755 if (item)
11756 item_count += item.GetNumberOfItems();
11757 }
11758 return item_count;
11759 }
11760
11762 float GetUnitWeight(bool include_wetness = true)
11763 {
11764 float weight = 0;
11765 float wetness = 1;
11766 if (include_wetness)
11767 wetness += GetWet();
11768 if (IsSplitable()) //quantity determines size of the stack
11769 {
11770 weight = wetness * m_ConfigWeight;
11771 }
11772 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
11773 {
11774 weight = 1;
11775 }
11776 return weight;
11777 }
11778
11779 //-----------------------------------------------------------------
11780
11781 override void ClearInventory()
11782 {
11783 GameInventory inventory = GetInventory();
11784 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
11785 {
11786 array<EntityAI> items = new array<EntityAI>;
11787 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
11788 for (int i = 0; i < items.Count(); ++i)
11789 {
11790 ItemBase item = ItemBase.Cast(items.Get(i));
11791 if (item)
11792 {
11793 g_Game.ObjectDelete(item);
11794 }
11795 }
11796 }
11797 }
11798
11799 //------------------------- Energy
11800
11801 //----------------------------------------------------------------
11802 float GetEnergy()
11803 {
11804 float energy = 0;
11805 if (HasEnergyManager())
11806 {
11807 energy = GetCompEM().GetEnergy();
11808 }
11809 return energy;
11810 }
11811
11812
11813 override void OnEnergyConsumed()
11814 {
11815 super.OnEnergyConsumed();
11816
11818 }
11819
11820 override void OnEnergyAdded()
11821 {
11822 super.OnEnergyAdded();
11823
11825 }
11826
11827 // Converts energy (from Energy Manager) to quantity, if enabled.
11829 {
11830 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
11831 {
11832 if (HasQuantity())
11833 {
11834 float energy_0to1 = GetCompEM().GetEnergy0To1();
11835 SetQuantityNormalized(energy_0to1);
11836 }
11837 }
11838 }
11839
11840 //----------------------------------------------------------------
11841 float GetHeatIsolationInit()
11842 {
11843 return ConfigGetFloat("heatIsolation");
11844 }
11845
11846 float GetHeatIsolation()
11847 {
11848 return m_HeatIsolation;
11849 }
11850
11851 float GetDryingIncrement(string pIncrementName)
11852 {
11853 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
11854 if (g_Game.ConfigIsExisting(paramPath))
11855 return g_Game.ConfigGetFloat(paramPath);
11856
11857 return 0.0;
11858 }
11859
11860 float GetSoakingIncrement(string pIncrementName)
11861 {
11862 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
11863 if (g_Game.ConfigIsExisting(paramPath))
11864 return g_Game.ConfigGetFloat(paramPath);
11865
11866 return 0.0;
11867 }
11868 //----------------------------------------------------------------
11869 override void SetWet(float value, bool allow_client = false)
11870 {
11871 if (!IsServerCheck(allow_client))
11872 return;
11873
11874 float min = GetWetMin();
11875 float max = GetWetMax();
11876
11877 float previousValue = m_VarWet;
11878
11879 m_VarWet = Math.Clamp(value, min, max);
11880
11881 if (previousValue != m_VarWet)
11882 {
11883 SetVariableMask(VARIABLE_WET);
11884 OnWetChanged(m_VarWet, previousValue);
11885 }
11886 }
11887 //----------------------------------------------------------------
11888 override void AddWet(float value)
11889 {
11890 SetWet(GetWet() + value);
11891 }
11892 //----------------------------------------------------------------
11893 override void SetWetMax()
11894 {
11896 }
11897 //----------------------------------------------------------------
11898 override float GetWet()
11899 {
11900 return m_VarWet;
11901 }
11902 //----------------------------------------------------------------
11903 override float GetWetMax()
11904 {
11905 return m_VarWetMax;
11906 }
11907 //----------------------------------------------------------------
11908 override float GetWetMin()
11909 {
11910 return m_VarWetMin;
11911 }
11912 //----------------------------------------------------------------
11913 override float GetWetInit()
11914 {
11915 return m_VarWetInit;
11916 }
11917 //----------------------------------------------------------------
11918 override void OnWetChanged(float newVal, float oldVal)
11919 {
11920 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
11921 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
11922 if (newLevel != oldLevel)
11923 {
11924 OnWetLevelChanged(newLevel,oldLevel);
11925 }
11926 }
11927
11928 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
11929 {
11930 SetWeightDirty();
11931 }
11932
11933 override EWetnessLevel GetWetLevel()
11934 {
11935 return GetWetLevelInternal(m_VarWet);
11936 }
11937
11938 //----------------------------------------------------------------
11939
11940 override void SetStoreLoad(bool value)
11941 {
11942 m_IsStoreLoad = value;
11943 }
11944
11945 override bool IsStoreLoad()
11946 {
11947 return m_IsStoreLoad;
11948 }
11949
11950 override void SetStoreLoadedQuantity(float value)
11951 {
11952 m_StoreLoadedQuantity = value;
11953 }
11954
11955 override float GetStoreLoadedQuantity()
11956 {
11957 return m_StoreLoadedQuantity;
11958 }
11959
11960 //----------------------------------------------------------------
11961
11962 float GetItemModelLength()
11963 {
11964 if (ConfigIsExisting("itemModelLength"))
11965 {
11966 return ConfigGetFloat("itemModelLength");
11967 }
11968 return 0;
11969 }
11970
11971 float GetItemAttachOffset()
11972 {
11973 if (ConfigIsExisting("itemAttachOffset"))
11974 {
11975 return ConfigGetFloat("itemAttachOffset");
11976 }
11977 return 0;
11978 }
11979
11980 override void SetCleanness(int value, bool allow_client = false)
11981 {
11982 if (!IsServerCheck(allow_client))
11983 return;
11984
11985 int previousValue = m_Cleanness;
11986
11987 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
11988
11989 if (previousValue != m_Cleanness)
11990 SetVariableMask(VARIABLE_CLEANNESS);
11991 }
11992
11993 override int GetCleanness()
11994 {
11995 return m_Cleanness;
11996 }
11997
11999 {
12000 return true;
12001 }
12002
12003 //----------------------------------------------------------------
12004 // ATTACHMENT LOCKING
12005 // Getters relevant to generic ActionLockAttachment
12006 int GetLockType()
12007 {
12008 return m_LockType;
12009 }
12010
12011 string GetLockSoundSet()
12012 {
12013 return m_LockSoundSet;
12014 }
12015
12016 //----------------------------------------------------------------
12017 //------------------------- Color
12018 // sets items color variable given color components
12019 override void SetColor(int r, int g, int b, int a)
12020 {
12025 SetVariableMask(VARIABLE_COLOR);
12026 }
12028 override void GetColor(out int r,out int g,out int b,out int a)
12029 {
12034 }
12035
12036 bool IsColorSet()
12037 {
12038 return IsVariableSet(VARIABLE_COLOR);
12039 }
12040
12042 string GetColorString()
12043 {
12044 int r,g,b,a;
12045 GetColor(r,g,b,a);
12046 r = r/255;
12047 g = g/255;
12048 b = b/255;
12049 a = a/255;
12050 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12051 }
12052 //----------------------------------------------------------------
12053 //------------------------- LiquidType
12054
12055 override void SetLiquidType(int value, bool allow_client = false)
12056 {
12057 if (!IsServerCheck(allow_client))
12058 return;
12059
12060 int old = m_VarLiquidType;
12061 m_VarLiquidType = value;
12062 OnLiquidTypeChanged(old,value);
12063 SetVariableMask(VARIABLE_LIQUIDTYPE);
12064 }
12065
12066 int GetLiquidTypeInit()
12067 {
12068 return ConfigGetInt("varLiquidTypeInit");
12069 }
12070
12071 override int GetLiquidType()
12072 {
12073 return m_VarLiquidType;
12074 }
12075
12076 protected void OnLiquidTypeChanged(int oldType, int newType)
12077 {
12078 if (newType == LIQUID_NONE && GetIsFrozen())
12079 SetFrozen(false);
12080 }
12081
12083 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12084 {
12085 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12086 }
12087
12088 // -------------------------------------------------------------------------
12090 void OnInventoryEnter(Man player)
12091 {
12092 PlayerBase nplayer;
12093 if (PlayerBase.CastTo(nplayer, player))
12094 {
12095 m_CanPlayImpactSound = true;
12096 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12097 }
12098 }
12099
12100 // -------------------------------------------------------------------------
12102 void OnInventoryExit(Man player)
12103 {
12104 PlayerBase nplayer;
12105 if (PlayerBase.CastTo(nplayer,player))
12106 {
12107 nplayer.SetEnableQuickBarEntityShortcut(this, false);
12108 }
12109
12110 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12111
12112 if (HasEnergyManager())
12113 {
12114 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12115 }
12116 }
12117
12118 // ADVANCED PLACEMENT EVENTS
12119 override void OnPlacementStarted(Man player)
12120 {
12121 super.OnPlacementStarted(player);
12122
12123 SetTakeable(false);
12124 }
12125
12126 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12127 {
12128 if (m_AdminLog)
12129 {
12130 m_AdminLog.OnPlacementComplete(player, this);
12131 }
12132
12133 super.OnPlacementComplete(player, position, orientation);
12134 }
12135
12136 //-----------------------------
12137 // AGENT SYSTEM
12138 //-----------------------------
12139 //--------------------------------------------------------------------------
12140 bool ContainsAgent(int agent_id)
12141 {
12142 if (agent_id & m_AttachedAgents)
12143 {
12144 return true;
12145 }
12146 else
12147 {
12148 return false;
12149 }
12150 }
12151
12152 //--------------------------------------------------------------------------
12153 override void RemoveAgent(int agent_id)
12154 {
12155 if (ContainsAgent(agent_id))
12156 {
12157 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12158 }
12159 }
12160
12161 //--------------------------------------------------------------------------
12162 override void RemoveAllAgents()
12163 {
12164 m_AttachedAgents = 0;
12165 }
12166 //--------------------------------------------------------------------------
12167 override void RemoveAllAgentsExcept(int agent_to_keep)
12168 {
12169 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12170 }
12171 // -------------------------------------------------------------------------
12172 override void InsertAgent(int agent, float count = 1)
12173 {
12174 if (count < 1)
12175 return;
12176 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12178 }
12179
12181 void TransferAgents(int agents)
12182 {
12184 }
12185
12186 // -------------------------------------------------------------------------
12187 override int GetAgents()
12188 {
12189 return m_AttachedAgents;
12190 }
12191 //----------------------------------------------------------------------
12192
12193 /*int GetContaminationType()
12194 {
12195 int contamination_type;
12196
12197 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12198 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12199 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12200 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12201
12202 Edible_Base edible = Edible_Base.Cast(this);
12203 int agents = GetAgents();
12204 if (edible)
12205 {
12206 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12207 if (profile)
12208 {
12209 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12210 }
12211 }
12212 if (agents & CONTAMINATED_MASK)
12213 {
12214 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12215 }
12216 if (agents & POISONED_MASK)
12217 {
12218 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12219 }
12220 if (agents & NERVE_GAS_MASK)
12221 {
12222 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12223 }
12224 if (agents & DIRTY_MASK)
12225 {
12226 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12227 }
12228
12229 return agents;
12230 }*/
12231
12232 // -------------------------------------------------------------------------
12233 bool LoadAgents(ParamsReadContext ctx, int version)
12234 {
12235 if (!ctx.Read(m_AttachedAgents))
12236 return false;
12237 return true;
12238 }
12239 // -------------------------------------------------------------------------
12241 {
12242
12244 }
12245 // -------------------------------------------------------------------------
12246
12248 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12249 {
12250 super.CheckForRoofLimited(timeTresholdMS);
12251
12252 float time = g_Game.GetTime();
12253 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12254 {
12255 m_PreviousRoofTestTime = time;
12256 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12257 }
12258 }
12259
12260 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12261 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12262 {
12263 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12264 {
12265 return 0;
12266 }
12267
12268 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12269 {
12270 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12271 if (filter)
12272 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12273 else
12274 return 0;//otherwise return 0 when no filter attached
12275 }
12276
12277 string subclassPath, entryName;
12278
12279 switch (type)
12280 {
12281 case DEF_BIOLOGICAL:
12282 entryName = "biological";
12283 break;
12284 case DEF_CHEMICAL:
12285 entryName = "chemical";
12286 break;
12287 default:
12288 entryName = "biological";
12289 break;
12290 }
12291
12292 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12293
12294 return g_Game.ConfigGetFloat(subclassPath + entryName);
12295 }
12296
12297
12298
12300 override void EEOnCECreate()
12301 {
12302 if (!IsMagazine())
12304
12306 }
12307
12308
12309 //-------------------------
12310 // OPEN/CLOSE USER ACTIONS
12311 //-------------------------
12313 void Open();
12314 void Close();
12315 bool IsOpen()
12316 {
12317 return true;
12318 }
12319
12320 override bool CanDisplayCargo()
12321 {
12322 return IsOpen();
12323 }
12324
12325
12326 // ------------------------------------------------------------
12327 // CONDITIONS
12328 // ------------------------------------------------------------
12329 override bool CanPutInCargo(EntityAI parent)
12330 {
12331 if (parent)
12332 {
12333 if (parent.IsInherited(DayZInfected))
12334 return true;
12335
12336 if (!parent.IsRuined())
12337 return true;
12338 }
12339
12340 return true;
12341 }
12342
12343 override bool CanPutAsAttachment(EntityAI parent)
12344 {
12345 if (!super.CanPutAsAttachment(parent))
12346 {
12347 return false;
12348 }
12349
12350 if (!IsRuined() && !parent.IsRuined())
12351 {
12352 return true;
12353 }
12354
12355 return false;
12356 }
12357
12358 override bool CanReceiveItemIntoCargo(EntityAI item)
12359 {
12360 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12361 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12362 // return false;
12363
12364 return super.CanReceiveItemIntoCargo(item);
12365 }
12366
12367 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12368 {
12369 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12370 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12371 // return false;
12372
12373 GameInventory attachmentInv = attachment.GetInventory();
12374 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12375 {
12376 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12377 return false;
12378 }
12379
12380 InventoryLocation loc = new InventoryLocation();
12381 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12382 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12383 return false;
12384
12385 return super.CanReceiveAttachment(attachment, slotId);
12386 }
12387
12388 override bool CanReleaseAttachment(EntityAI attachment)
12389 {
12390 if (!super.CanReleaseAttachment(attachment))
12391 return false;
12392
12393 return GetInventory().AreChildrenAccessible();
12394 }
12395
12396 /*override bool CanLoadAttachment(EntityAI attachment)
12397 {
12398 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12399 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12400 // return false;
12401
12402 GameInventory attachmentInv = attachment.GetInventory();
12403 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12404 {
12405 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12406 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12407
12408 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12409 return false;
12410 }
12411
12412 return super.CanLoadAttachment(attachment);
12413 }*/
12414
12415 // Plays muzzle flash particle effects
12416 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12417 {
12418 int id = muzzle_owner.GetMuzzleID();
12419 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12420
12421 if (WPOF_array)
12422 {
12423 for (int i = 0; i < WPOF_array.Count(); i++)
12424 {
12425 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12426
12427 if (WPOF)
12428 {
12429 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12430 }
12431 }
12432 }
12433 }
12434
12435 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12436 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12437 {
12438 int id = muzzle_owner.GetMuzzleID();
12439 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12440
12441 if (WPOBE_array)
12442 {
12443 for (int i = 0; i < WPOBE_array.Count(); i++)
12444 {
12445 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12446
12447 if (WPOBE)
12448 {
12449 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12450 }
12451 }
12452 }
12453 }
12454
12455 // Plays all weapon overheating particles
12456 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12457 {
12458 int id = muzzle_owner.GetMuzzleID();
12459 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12460
12461 if (WPOOH_array)
12462 {
12463 for (int i = 0; i < WPOOH_array.Count(); i++)
12464 {
12465 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12466
12467 if (WPOOH)
12468 {
12469 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12470 }
12471 }
12472 }
12473 }
12474
12475 // Updates all weapon overheating particles
12476 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12477 {
12478 int id = muzzle_owner.GetMuzzleID();
12479 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12480
12481 if (WPOOH_array)
12482 {
12483 for (int i = 0; i < WPOOH_array.Count(); i++)
12484 {
12485 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12486
12487 if (WPOOH)
12488 {
12489 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12490 }
12491 }
12492 }
12493 }
12494
12495 // Stops overheating particles
12496 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12497 {
12498 int id = muzzle_owner.GetMuzzleID();
12499 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12500
12501 if (WPOOH_array)
12502 {
12503 for (int i = 0; i < WPOOH_array.Count(); i++)
12504 {
12505 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12506
12507 if (WPOOH)
12508 {
12509 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12510 }
12511 }
12512 }
12513 }
12514
12515 //----------------------------------------------------------------
12516 //Item Behaviour - unified approach
12517 override bool IsHeavyBehaviour()
12518 {
12519 if (m_ItemBehaviour == 0)
12520 {
12521 return true;
12522 }
12523
12524 return false;
12525 }
12526
12527 override bool IsOneHandedBehaviour()
12528 {
12529 if (m_ItemBehaviour == 1)
12530 {
12531 return true;
12532 }
12533
12534 return false;
12535 }
12536
12537 override bool IsTwoHandedBehaviour()
12538 {
12539 if (m_ItemBehaviour == 2)
12540 {
12541 return true;
12542 }
12543
12544 return false;
12545 }
12546
12547 bool IsDeployable()
12548 {
12549 return false;
12550 }
12551
12553 float GetDeployTime()
12554 {
12555 return UATimeSpent.DEFAULT_DEPLOY;
12556 }
12557
12558
12559 //----------------------------------------------------------------
12560 // Item Targeting (User Actions)
12561 override void SetTakeable(bool pState)
12562 {
12563 m_IsTakeable = pState;
12564 SetSynchDirty();
12565 }
12566
12567 override bool IsTakeable()
12568 {
12569 return m_IsTakeable;
12570 }
12571
12572 // For cases where we want to show object widget which cant be taken to hands
12574 {
12575 return false;
12576 }
12577
12579 protected void PreLoadSoundAttachmentType()
12580 {
12581 string att_type = "None";
12582
12583 if (ConfigIsExisting("soundAttType"))
12584 {
12585 att_type = ConfigGetString("soundAttType");
12586 }
12587
12588 m_SoundAttType = att_type;
12589 }
12590
12591 override string GetAttachmentSoundType()
12592 {
12593 return m_SoundAttType;
12594 }
12595
12596 //----------------------------------------------------------------
12597 //SOUNDS - ItemSoundHandler
12598 //----------------------------------------------------------------
12599
12600 string GetPlaceSoundset(); // played when deploy starts
12601 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
12602 string GetDeploySoundset(); // played when deploy sucessfully finishes
12603 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
12604 string GetFoldSoundset(); // played when fold sucessfully finishes
12605
12607 {
12608 if (!m_ItemSoundHandler)
12610
12611 return m_ItemSoundHandler;
12612 }
12613
12614 // override to initialize sounds
12615 protected void InitItemSounds()
12616 {
12617 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
12618 return;
12619
12621
12622 if (GetPlaceSoundset() != string.Empty)
12623 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
12624
12625 if (GetDeploySoundset() != string.Empty)
12626 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
12627
12628 SoundParameters params = new SoundParameters();
12629 params.m_Loop = true;
12630 if (GetLoopDeploySoundset() != string.Empty)
12631 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
12632 }
12633
12634 // Start sound using ItemSoundHandler
12635 void StartItemSoundServer(int id, int slotId)
12636 {
12637 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12638 {
12639 m_SoundSyncSlotID = slotId;
12640 m_SoundSyncPlay = id;
12641
12642 SetSynchDirty();
12643
12644 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
12645 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
12646 }
12647 }
12648
12649 void StartItemSoundServer(int id)
12650 {
12651 StartItemSoundServer(id, InventorySlots.INVALID);
12652 }
12653
12654 // Stop sound using ItemSoundHandler
12655 void StopItemSoundServer(int id)
12656 {
12657 if (!g_Game.IsServer())
12658 return;
12659
12660 m_SoundSyncStop = id;
12661 SetSynchDirty();
12662
12663 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
12664 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
12665 }
12666
12667 protected void ClearStartItemSoundServer()
12668 {
12669 m_SoundSyncPlay = 0;
12670 m_SoundSyncSlotID = InventorySlots.INVALID;
12671 }
12672
12673 protected void ClearStopItemSoundServer()
12674 {
12675 m_SoundSyncStop = 0;
12676 }
12677
12678 void OnApply(PlayerBase player);
12679
12681 {
12682 return 1.0;
12683 };
12684 //returns applicable selection
12685 array<string> GetHeadHidingSelection()
12686 {
12688 }
12689
12691 {
12693 }
12694
12695 WrittenNoteData GetWrittenNoteData() {};
12696
12698 {
12699 SetDynamicPhysicsLifeTime(0.01);
12700 m_ItemBeingDroppedPhys = false;
12701 }
12702
12704 {
12705 array<string> zone_names = new array<string>;
12706 GetDamageZones(zone_names);
12707 for (int i = 0; i < zone_names.Count(); i++)
12708 {
12709 SetHealthMax(zone_names.Get(i),"Health");
12710 }
12711 SetHealthMax("","Health");
12712 }
12713
12715 void SetZoneDamageCEInit()
12716 {
12717 float global_health = GetHealth01("","Health");
12718 array<string> zones = new array<string>;
12719 GetDamageZones(zones);
12720 //set damage of all zones to match global health level
12721 for (int i = 0; i < zones.Count(); i++)
12722 {
12723 SetHealth01(zones.Get(i),"Health",global_health);
12724 }
12725 }
12726
12728 bool IsCoverFaceForShave(string slot_name)
12729 {
12730 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12731 }
12732
12733 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12734 {
12735 if (!hasRootAsPlayer)
12736 {
12737 if (refParentIB)
12738 {
12739 // parent is wet
12740 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12741 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12742 // parent has liquid inside
12743 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12744 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
12745 // drying
12746 else if (m_VarWet > m_VarWetMin)
12747 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
12748 }
12749 else
12750 {
12751 // drying on ground or inside non-itembase (car, ...)
12752 if (m_VarWet > m_VarWetMin)
12753 AddWet(-1 * delta * GetDryingIncrement("ground"));
12754 }
12755 }
12756 }
12757
12758 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12759 {
12761 {
12762 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
12763 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
12764 {
12765 float heatPermCoef = 1.0;
12766 EntityAI ent = this;
12767 while (ent)
12768 {
12769 heatPermCoef *= ent.GetHeatPermeabilityCoef();
12770 ent = ent.GetHierarchyParent();
12771 }
12772
12773 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
12774 }
12775 }
12776 }
12777
12778 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
12779 {
12780 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
12781 EntityAI parent = GetHierarchyParent();
12782 if (!parent)
12783 {
12784 hasParent = false;
12785 hasRootAsPlayer = false;
12786 }
12787 else
12788 {
12789 hasParent = true;
12790 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
12791 refParentIB = ItemBase.Cast(parent);
12792 }
12793 }
12794
12795 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
12796 {
12797 // this is stub, implemented on Edible_Base
12798 }
12799
12800 bool CanDecay()
12801 {
12802 // return true used on selected food clases so they can decay
12803 return false;
12804 }
12805
12806 protected bool CanProcessDecay()
12807 {
12808 // this is stub, implemented on Edible_Base class
12809 // used to determine whether it is still necessary for the food to decay
12810 return false;
12811 }
12812
12813 protected bool CanHaveWetness()
12814 {
12815 // return true used on selected items that have a wetness effect
12816 return false;
12817 }
12818
12820 bool CanBeConsumed(ConsumeConditionData data = null)
12821 {
12822 return !GetIsFrozen() && IsOpen();
12823 }
12824
12825 override void ProcessVariables()
12826 {
12827 bool hasParent = false, hasRootAsPlayer = false;
12828 ItemBase refParentIB;
12829
12830 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
12831 bool foodDecay = g_Game.IsFoodDecayEnabled();
12832
12833 if (wwtu || foodDecay)
12834 {
12835 bool processWetness = wwtu && CanHaveWetness();
12836 bool processTemperature = wwtu && CanHaveTemperature();
12837 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
12838
12839 if (processWetness || processTemperature || processDecay)
12840 {
12841 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
12842
12843 if (processWetness)
12844 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12845
12846 if (processTemperature)
12847 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12848
12849 if (processDecay)
12850 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
12851 }
12852 }
12853 }
12854
12857 {
12858 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
12859 }
12860
12861 override float GetTemperatureFreezeThreshold()
12862 {
12864 return Liquid.GetFreezeThreshold(GetLiquidType());
12865
12866 return super.GetTemperatureFreezeThreshold();
12867 }
12868
12869 override float GetTemperatureThawThreshold()
12870 {
12872 return Liquid.GetThawThreshold(GetLiquidType());
12873
12874 return super.GetTemperatureThawThreshold();
12875 }
12876
12877 override float GetItemOverheatThreshold()
12878 {
12880 return Liquid.GetBoilThreshold(GetLiquidType());
12881
12882 return super.GetItemOverheatThreshold();
12883 }
12884
12885 override float GetTemperatureFreezeTime()
12886 {
12887 if (HasQuantity())
12888 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
12889
12890 return super.GetTemperatureFreezeTime();
12891 }
12892
12893 override float GetTemperatureThawTime()
12894 {
12895 if (HasQuantity())
12896 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
12897
12898 return super.GetTemperatureThawTime();
12899 }
12900
12902 void AffectLiquidContainerOnFill(int liquid_type, float amount);
12904 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
12905
12906 bool IsCargoException4x3(EntityAI item)
12907 {
12908 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
12909 }
12910
12912 {
12913 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
12914 }
12915
12917 void AddLightSourceItem(ItemBase lightsource)
12918 {
12919 m_LightSourceItem = lightsource;
12920 }
12921
12923 {
12924 m_LightSourceItem = null;
12925 }
12926
12928 {
12929 return m_LightSourceItem;
12930 }
12931
12933 array<int> GetValidFinishers()
12934 {
12935 return null;
12936 }
12937
12939 bool GetActionWidgetOverride(out typename name)
12940 {
12941 return false;
12942 }
12943
12944 bool PairWithDevice(notnull ItemBase otherDevice)
12945 {
12946 if (g_Game.IsServer())
12947 {
12948 ItemBase explosive = otherDevice;
12950 if (!trg)
12951 {
12952 trg = RemoteDetonatorTrigger.Cast(otherDevice);
12953 explosive = this;
12954 }
12955
12956 explosive.PairRemote(trg);
12957 trg.SetControlledDevice(explosive);
12958
12959 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
12960 trg.SetPersistentPairID(persistentID);
12961 explosive.SetPersistentPairID(persistentID);
12962
12963 return true;
12964 }
12965 return false;
12966 }
12967
12969 float GetBaitEffectivity()
12970 {
12971 float ret = 1.0;
12972 if (HasQuantity())
12973 ret *= GetQuantityNormalized();
12974 ret *= GetHealth01();
12975
12976 return ret;
12977 }
12978
12979 #ifdef DEVELOPER
12980 override void SetDebugItem()
12981 {
12982 super.SetDebugItem();
12983 _itemBase = this;
12984 }
12985
12986 override string GetDebugText()
12987 {
12988 string text = super.GetDebugText();
12989
12990 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
12991 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
12992
12993 return text;
12994 }
12995 #endif
12996
12997 bool CanBeUsedForSuicide()
12998 {
12999 return true;
13000 }
13001
13003 //DEPRECATED BELOW
13005 // Backwards compatibility
13006 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13007 {
13008 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13009 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13010 }
13011
13012 // replaced by ItemSoundHandler
13013 protected EffectSound m_SoundDeployFinish;
13014 protected EffectSound m_SoundPlace;
13015 protected EffectSound m_DeployLoopSoundEx;
13016 protected EffectSound m_SoundDeploy;
13017 bool m_IsPlaceSound;
13018 bool m_IsDeploySound;
13020
13021 string GetDeployFinishSoundset();
13022 void PlayDeploySound();
13023 void PlayDeployFinishSound();
13024 void PlayPlaceSound();
13025 void PlayDeployLoopSoundEx();
13026 void StopDeployLoopSoundEx();
13027 void SoundSynchRemoteReset();
13028 void SoundSynchRemote();
13029 bool UsesGlobalDeploy(){return false;}
13030 bool CanPlayDeployLoopSound(){return false;}
13032 bool IsPlaceSound(){return m_IsPlaceSound;}
13033 bool IsDeploySound(){return m_IsDeploySound;}
13034 void SetIsPlaceSound(bool is_place_sound);
13035 void SetIsDeploySound(bool is_deploy_sound);
13036
13037 [Obsolete("Use ItemSoundHandler instead")]
13039 void PlayAttachSound(string slot_type)
13040 {
13041 if (!g_Game.IsDedicatedServer())
13042 {
13043 if (ConfigIsExisting("attachSoundSet"))
13044 {
13045 string cfg_path = "";
13046 string soundset = "";
13047 string type_name = GetType();
13048
13049 TStringArray cfg_soundset_array = new TStringArray;
13050 TStringArray cfg_slot_array = new TStringArray;
13051 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13052 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13053
13054 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13055 {
13056 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13057 {
13058 if (cfg_slot_array[i] == slot_type)
13059 {
13060 soundset = cfg_soundset_array[i];
13061 break;
13062 }
13063 }
13064 }
13065
13066 if (soundset != "")
13067 {
13068 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13069 sound.SetAutodestroy(true);
13070 }
13071 }
13072 }
13073 }
13074
13075 void PlayDetachSound(string slot_type) {}
13076}
13077
13078EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13079{
13080 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13081 if (entity)
13082 {
13083 bool is_item = entity.IsInherited(ItemBase);
13084 if (is_item && full_quantity)
13085 {
13086 ItemBase item = ItemBase.Cast(entity);
13087 item.SetQuantity(item.GetQuantityInit());
13088 }
13089 }
13090 else
13091 {
13092 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13093 return NULL;
13094 }
13095 return entity;
13096}
13097
13098void SetupSpawnedItem(ItemBase item, float health, float quantity)
13099{
13100 if (item)
13101 {
13102 if (health > 0)
13103 item.SetHealth("", "", health);
13104
13105 if (item.CanHaveTemperature())
13106 {
13107 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13108 if (item.CanFreeze())
13109 item.SetFrozen(false);
13110 }
13111
13112 if (item.HasEnergyManager())
13113 {
13114 if (quantity >= 0)
13115 {
13116 item.GetCompEM().SetEnergy0To1(quantity);
13117 }
13118 else
13119 {
13120 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13121 }
13122 }
13123 else if (item.IsMagazine())
13124 {
13125 Magazine mag = Magazine.Cast(item);
13126 if (quantity >= 0)
13127 {
13128 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13129 }
13130 else
13131 {
13132 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13133 }
13134
13135 }
13136 else
13137 {
13138 if (quantity >= 0)
13139 {
13140 item.SetQuantityNormalized(quantity, false);
13141 }
13142 else
13143 {
13144 item.SetQuantity(Math.AbsFloat(quantity));
13145 }
13146
13147 }
13148 }
13149}
13150
13151#ifdef DEVELOPER
13152ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13153#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()