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

◆ GetQuantityMin()

override int SpawnItemOnLocation::GetQuantityMin ( )
protected

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

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

Используется в InventoryItem::GetQuantityNormalized(), InventoryItem::HasQuantity(), InventoryItem::InitItemVariables(), InventoryItem::OnWasAttached(), InventoryItem::OnWasDetached(), Release(), InventoryItem::SetQuantity() и InventoryItem::SetQuantityToMinimum().