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

◆ GetSingleInventoryItemWeightEx()

override float SpawnItemOnLocation::GetSingleInventoryItemWeightEx ( )
protected

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

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

Используется в InventoryItem::GetSingleInventoryItemWeight() и Entity::OnAction().