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

◆ GetQuantityMax()

override int SpawnItemOnLocation::GetQuantityMax ( )
protected

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

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

Используется в Bottle_Base::AffectLiquidContainerOnFill(), FilteringBottle::AffectLiquidContainerOnFill(), Bottle_Base::AffectLiquidContainerOnTransfer(), FilteringBottle::AffectLiquidContainerOnTransfer(), CalcAndSetQuantity(), InventoryItem::CanBeCombined(), Capture(), InventoryItem::ComputeQuantityUsedEx(), DisinfectantAlcohol::GetDisinfectQuantity(), DisinfectantSpray::GetDisinfectQuantity(), IodineTincture::GetDisinfectQuantity(), Mask_Base::GetFilterQuantity01(), Mask_Base::GetFilterQuantityMax(), InventoryItem::GetQuantityNormalized(), InventoryItem::HasQuantity(), InventoryItem::IsFullQuantity(), InventoryItem::OnAction(), InventoryItem::SetQuantity(), InventoryItem::SetQuantityMax(), InventoryItem::SetQuantityNormalized(), BroomBase::UpdateParticle() и ItemBase::UpdateSelections().