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

◆ GetLiquidTypeInit()

int SpawnItemOnLocation::GetLiquidTypeInit ( )
protected

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

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

Используется в DisinfectantAlcohol::InitItemVariables(), DisinfectantSpray::InitItemVariables(), InventoryItem::InitItemVariables(), IodineTincture::InitItemVariables() и InventoryItem::OnQuantityChanged().