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

◆ GetSingleInventoryItemWeight()

float SpawnItemOnLocation::GetSingleInventoryItemWeight ( )
protected

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

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