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

◆ GetWetMin()

override float SpawnItemOnLocation::GetWetMin ( )
protected

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

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

Используется в Entity::HasWetness(), InventoryItem::InitItemVariables() и InventoryItem::SetWet().