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

◆ GetWeightSpecialized()

float SpawnItemOnLocation::GetWeightSpecialized ( bool forceRecalc = false)
protected

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

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

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