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

◆ GetDryingIncrement()

float SpawnItemOnLocation::GetDryingIncrement ( string pIncrementName)
protected

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

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

Используется в InventoryItem::ProcessItemWetness().