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

◆ OnEnergyAdded()

override void SpawnItemOnLocation::OnEnergyAdded ( )
protected

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

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