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

◆ OnOverheatingDecay()

void SpawnItemOnLocation::OnOverheatingDecay ( )
private

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

5406{
5407 override bool CanPutAsAttachment(EntityAI parent)
5408 {
5409 return true;
5410 }
5411};
5412
5413//const bool QUANTITY_DEBUG_REMOVE_ME = false;
5414
5415class ItemBase extends InventoryItem
5416{
5420
5422
5423 static int m_DebugActionsMask;
5425 // ============================================
5426 // Variable Manipulation System
5427 // ============================================
5428 // Quantity
5429
5430 float m_VarQuantity;
5431 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
5433 int m_VarQuantityMin;
5434 int m_VarQuantityMax;
5435 int m_Count;
5436 float m_VarStackMax;
5437 float m_StoreLoadedQuantity = float.LOWEST;
5438 // Wet
5439 float m_VarWet;
5440 float m_VarWetPrev;//for client to know wetness changed during synchronization
5441 float m_VarWetInit;
5442 float m_VarWetMin;
5443 float m_VarWetMax;
5444 // Cleanness
5445 int m_Cleanness;
5446 int m_CleannessInit;
5447 int m_CleannessMin;
5448 int m_CleannessMax;
5449 // impact sounds
5451 bool m_CanPlayImpactSound = true;
5452 float m_ImpactSpeed;
5454 //
5455 float m_HeatIsolation;
5456 float m_ItemModelLength;
5457 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
5459 int m_VarLiquidType;
5460 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
5461 int m_QuickBarBonus;
5462 bool m_IsBeingPlaced;
5463 bool m_IsHologram;
5464 bool m_IsTakeable;
5465 bool m_ThrowItemOnDrop;
5468 bool m_FixDamageSystemInit = false; //can be changed on storage version check
5469 bool can_this_be_combined; //Check if item can be combined
5470 bool m_CanThisBeSplit; //Check if item can be split
5471 bool m_IsStoreLoad = false;
5472 bool m_CanShowQuantity;
5473 bool m_HasQuantityBar;
5474 protected bool m_CanBeDigged;
5475 protected bool m_IsResultOfSplit
5476
5477 string m_SoundAttType;
5478 // items color variables
5483 //-------------------------------------------------------
5484
5485 // light source managing
5487
5491
5492 //==============================================
5493 // agent system
5494 private int m_AttachedAgents;
5495
5497 void TransferModifiers(PlayerBase reciever);
5498
5499
5500 // Weapons & suppressors particle effects
5505 static int m_LastRegisteredWeaponID = 0;
5506
5507 // Overheating effects
5509 float m_OverheatingShots;
5510 ref Timer m_CheckOverheating;
5511 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
5512 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
5513 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
5514 ref array <ref OverheatingParticle> m_OverheatingParticles;
5515
5517 protected bool m_HideSelectionsBySlot;
5518
5519 // Admin Log
5520 PluginAdminLog m_AdminLog;
5521
5522 // misc
5523 ref Timer m_PhysDropTimer;
5524
5525 // Attachment Locking variables
5526 ref array<int> m_CompatibleLocks;
5527 protected int m_LockType;
5528 protected ref EffectSound m_LockingSound;
5529 protected string m_LockSoundSet;
5530
5531 // ItemSoundHandler
5532 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
5533 protected int m_SoundSyncPlay; // id for sound to play
5534 protected int m_SoundSyncStop; // id for sound to stop
5536
5537 //temperature
5538 private float m_TemperaturePerQuantityWeight;
5539
5540 // -------------------------------------------------------------------------
5541 void ItemBase()
5542 {
5543 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
5547
5548 if (!GetGame().IsDedicatedServer())
5549 {
5550 if (HasMuzzle())
5551 {
5553
5555 {
5557 }
5558 }
5559
5561 m_ActionsInitialize = false;
5562 }
5563
5564 m_OldLocation = null;
5565
5566 if (GetGame().IsServer())
5567 {
5568 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
5569 }
5570
5571 if (ConfigIsExisting("headSelectionsToHide"))
5572 {
5574 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
5575 }
5576
5577 m_HideSelectionsBySlot = false;
5578 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
5579 {
5580 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
5581 }
5582
5583 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
5584
5585 m_IsResultOfSplit = false;
5586
5588 }
5589
5590 override void InitItemVariables()
5591 {
5592 super.InitItemVariables();
5593
5594 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
5595 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
5596 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
5597 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
5598 m_VarStackMax = ConfigGetFloat("varStackMax");
5599 m_Count = ConfigGetInt("count");
5600
5601 m_CanShowQuantity = ConfigGetBool("quantityShow");
5602 m_HasQuantityBar = ConfigGetBool("quantityBar");
5603
5604 m_CleannessInit = ConfigGetInt("varCleannessInit");
5606 m_CleannessMin = ConfigGetInt("varCleannessMin");
5607 m_CleannessMax = ConfigGetInt("varCleannessMax");
5608
5609 m_WantPlayImpactSound = false;
5610 m_ImpactSpeed = 0.0;
5611
5612 m_VarWetInit = ConfigGetFloat("varWetInit");
5614 m_VarWetMin = ConfigGetFloat("varWetMin");
5615 m_VarWetMax = ConfigGetFloat("varWetMax");
5616
5617 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
5618 if (IsLiquidContainer() && GetQuantity() != 0)
5620 m_IsBeingPlaced = false;
5621 m_IsHologram = false;
5622 m_IsTakeable = true;
5623 m_CanBeMovedOverride = false;
5627 m_CanBeDigged = ConfigGetBool("canBeDigged");
5628
5629 m_CompatibleLocks = new array<int>();
5630 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
5631 m_LockType = ConfigGetInt("lockType");
5632
5633 //Define if item can be split and set ability to be combined accordingly
5634 m_CanThisBeSplit = false;
5635 can_this_be_combined = false;
5636 if (ConfigIsExisting("canBeSplit"))
5637 {
5638 can_this_be_combined = ConfigGetBool("canBeSplit");
5640 }
5641
5642 m_ItemBehaviour = -1;
5643 if (ConfigIsExisting("itemBehaviour"))
5644 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
5645
5646 //RegisterNetSyncVariableInt("m_VariablesMask");
5647 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
5648 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
5649 RegisterNetSyncVariableInt("m_VarLiquidType");
5650 RegisterNetSyncVariableInt("m_Cleanness",0,1);
5651
5652 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
5653 RegisterNetSyncVariableFloat("m_ImpactSpeed");
5654 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
5655
5656 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
5657 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
5658 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
5659 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
5660
5661 RegisterNetSyncVariableBool("m_IsBeingPlaced");
5662 RegisterNetSyncVariableBool("m_IsTakeable");
5663 RegisterNetSyncVariableBool("m_IsHologram");
5664
5665 InitItemSounds();
5667 {
5668 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
5669 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
5670 }
5671
5672 m_LockSoundSet = ConfigGetString("lockSoundSet");
5673
5675 if (ConfigIsExisting("temperaturePerQuantityWeight"))
5676 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
5677
5678 }
5679
5680 override int GetQuickBarBonus()
5681 {
5682 return m_QuickBarBonus;
5683 }
5684
5685 void InitializeActions()
5686 {
5688 if (!m_InputActionMap)
5689 {
5691 m_InputActionMap = iam;
5692 SetActions();
5694 }
5695 }
5696
5697 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
5698 {
5700 {
5701 m_ActionsInitialize = true;
5703 }
5704
5705 actions = m_InputActionMap.Get(action_input_type);
5706 }
5707
5708 void SetActions()
5709 {
5710 AddAction(ActionTakeItem);
5711 AddAction(ActionTakeItemToHands);
5712 AddAction(ActionWorldCraft);
5714 AddAction(ActionAttachWithSwitch);
5715 }
5716
5717 void SetActionAnimOverrides(); // Override action animation for specific item
5718
5719 void AddAction(typename actionName)
5720 {
5721 ActionBase action = ActionManagerBase.GetAction(actionName);
5722
5723 if (!action)
5724 {
5725 Debug.LogError("Action " + actionName + " dosn't exist!");
5726 return;
5727 }
5728
5729 typename ai = action.GetInputType();
5730 if (!ai)
5731 {
5732 m_ActionsInitialize = false;
5733 return;
5734 }
5735
5736 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
5737 if (!action_array)
5738 {
5739 action_array = new array<ActionBase_Basic>;
5740 m_InputActionMap.Insert(ai, action_array);
5741 }
5742 if (LogManager.IsActionLogEnable())
5743 {
5744 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
5745 }
5746
5747 if (action_array.Find(action) != -1)
5748 {
5749 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
5750 }
5751 else
5752 {
5753 action_array.Insert(action);
5754 }
5755 }
5756
5757 void RemoveAction(typename actionName)
5758 {
5759 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
5760 ActionBase action = player.GetActionManager().GetAction(actionName);
5761 typename ai = action.GetInputType();
5762 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
5763
5764 if (action_array)
5765 {
5766 action_array.RemoveItem(action);
5767 }
5768 }
5769
5770 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
5771 // Set -1 for params which should stay in default state
5772 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
5773 {
5774 ActionOverrideData overrideData = new ActionOverrideData();
5775 overrideData.m_CommandUID = commandUID;
5776 overrideData.m_CommandUIDProne = commandUIDProne;
5777 overrideData.m_StanceMask = stanceMask;
5778
5779 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
5780 if (!actionMap) // create new map of action > overidables map
5781 {
5782 actionMap = new TActionAnimOverrideMap();
5783 m_ItemActionOverrides.Insert(action, actionMap);
5784 }
5785
5786 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
5787
5788 }
5789
5790 void OnItemInHandsPlayerSwimStart(PlayerBase player);
5791
5792 ScriptedLightBase GetLight();
5793
5794 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
5795 void LoadParticleConfigOnFire(int id)
5796 {
5797 if (!m_OnFireEffect)
5799
5802
5803 string config_to_search = "CfgVehicles";
5804 string muzzle_owner_config;
5805
5806 if (!m_OnFireEffect.Contains(id))
5807 {
5808 if (IsInherited(Weapon))
5809 config_to_search = "CfgWeapons";
5810
5811 muzzle_owner_config = config_to_search + " " + GetType() + " ";
5812
5813 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
5814
5815 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
5816
5817 if (config_OnFire_subclass_count > 0)
5818 {
5819 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
5820
5821 for (int i = 0; i < config_OnFire_subclass_count; i++)
5822 {
5823 string particle_class = "";
5824 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
5825 string config_OnFire_entry = config_OnFire_class + particle_class;
5826 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
5827 WPOF_array.Insert(WPOF);
5828 }
5829
5830
5831 m_OnFireEffect.Insert(id, WPOF_array);
5832 }
5833 }
5834
5835 if (!m_OnBulletCasingEjectEffect.Contains(id))
5836 {
5837 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
5838 muzzle_owner_config = config_to_search + " " + GetType() + " ";
5839
5840 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
5841
5842 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
5843
5844 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
5845 {
5846 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
5847
5848 for (i = 0; i < config_OnBulletCasingEject_count; i++)
5849 {
5850 string particle_class2 = "";
5851 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
5852 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
5853 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
5854 WPOBE_array.Insert(WPOBE);
5855 }
5856
5857
5858 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
5859 }
5860 }
5861 }
5862
5863 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
5865 {
5868
5869 if (!m_OnOverheatingEffect.Contains(id))
5870 {
5871 string config_to_search = "CfgVehicles";
5872
5873 if (IsInherited(Weapon))
5874 config_to_search = "CfgWeapons";
5875
5876 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
5877 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
5878
5879 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
5880 {
5881
5882 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
5883
5885 {
5886 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
5887 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
5888 Error(error);
5889 return;
5890 }
5891
5892 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
5893 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
5894
5895
5896
5897 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
5898 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
5899
5900 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
5901 {
5902 string particle_class = "";
5903 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
5904 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
5905 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
5906
5907 if (entry_type == CT_CLASS)
5908 {
5909 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
5910 WPOOH_array.Insert(WPOF);
5911 }
5912 }
5913
5914
5915 m_OnOverheatingEffect.Insert(id, WPOOH_array);
5916 }
5917 }
5918 }
5919
5920 float GetOverheatingValue()
5921 {
5922 return m_OverheatingShots;
5923 }
5924
5925 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
5926 {
5927 if (m_MaxOverheatingValue > 0)
5928 {
5930
5931 if (!m_CheckOverheating)
5933
5935 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
5936
5937 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
5938 }
5939 }
5940
5941 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
5942 {
5944 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
5945
5947 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
5948
5950 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
5951
5953 {
5955 }
5956 }
5957
5959 {
5961 }
5962
5963 void OnOverheatingDecay()
5964 {
5965 if (m_MaxOverheatingValue > 0)
5966 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
5967 else
5969
5970 if (m_OverheatingShots <= 0)
5971 {
5974 }
5975 else
5976 {
5977 if (!m_CheckOverheating)
5979
5981 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
5982 }
5983
5984 CheckOverheating(this, "", this);
5985 }
5986
5987 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
5988 {
5990 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
5991 }
5992
5993 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
5994 {
5996 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
5998 }
5999
6000 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6001 {
6003 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6004 }
6005
6006 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
6007 {
6009 m_OverheatingParticles = new array<ref OverheatingParticle>;
6010
6011 OverheatingParticle OP = new OverheatingParticle();
6012 OP.RegisterParticle(p);
6013 OP.SetOverheatingLimitMin(min_heat_coef);
6014 OP.SetOverheatingLimitMax(max_heat_coef);
6015 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
6016
6017 m_OverheatingParticles.Insert(OP);
6018 }
6019
6020 float GetOverheatingCoef()
6021 {
6022 if (m_MaxOverheatingValue > 0)
6024
6025 return -1;
6026 }
6027
6029 {
6031 {
6032 float overheat_coef = GetOverheatingCoef();
6033 int count = m_OverheatingParticles.Count();
6034
6035 for (int i = count; i > 0; --i)
6036 {
6037 int id = i - 1;
6038 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6039 Particle p = OP.GetParticle();
6040
6041 float overheat_min = OP.GetOverheatingLimitMin();
6042 float overheat_max = OP.GetOverheatingLimitMax();
6043
6044 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
6045 {
6046 if (p)
6047 {
6048 p.Stop();
6049 OP.RegisterParticle(null);
6050 }
6051 }
6052 }
6053 }
6054 }
6055
6057 {
6059 {
6060 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
6061 {
6062 int id = i - 1;
6063 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6064
6065 if (OP)
6066 {
6067 Particle p = OP.GetParticle();
6068
6069 if (p)
6070 {
6071 p.Stop();
6072 }
6073
6074 delete OP;
6075 }
6076 }
6077
6078 m_OverheatingParticles.Clear();
6080 }
6081 }
6082
6084 float GetInfectionChance(int system = 0, Param param = null)
6085 {
6086 return 0.0;
6087 }
6088
6089
6090 float GetDisinfectQuantity(int system = 0, Param param1 = null)
6091 {
6092 return 250;//default value
6093 }
6094
6095 float GetFilterDamageRatio()
6096 {
6097 return 0;
6098 }
6099
6101 bool HasMuzzle()
6102 {
6103 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
6104 return true;
6105
6106 return false;
6107 }
6108
6110 int GetMuzzleID()
6111 {
6112 if (!m_WeaponTypeToID)
6114
6115 if (m_WeaponTypeToID.Contains(GetType()))
6116 {
6117 return m_WeaponTypeToID.Get(GetType());
6118 }
6119 else
6120 {
6121 // Register new weapon ID
6123 }
6124
6126 }
6127
6134 {
6135 return -1;
6136 }
6137
6138
6139
6140 // -------------------------------------------------------------------------
6141 void ~ItemBase()
6142 {
6143 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
6144 {
6145 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
6146 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6147
6148 if (r_index >= 0)
6149 {
6150 InventoryLocation r_il = new InventoryLocation;
6151 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6152
6153 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6154 int r_type = r_il.GetType();
6155 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6156 {
6157 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6158 }
6159 else if (r_type == InventoryLocationType.ATTACHMENT)
6160 {
6161 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6162 }
6163
6164 }
6165
6166 player.GetHumanInventory().ClearUserReservedLocation(this);
6167 }
6168
6169 if (m_LockingSound)
6170 SEffectManager.DestroyEffect(m_LockingSound);
6171 }
6172
6173
6174
6175 // -------------------------------------------------------------------------
6176 static int GetDebugActionsMask()
6177 {
6178 return ItemBase.m_DebugActionsMask;
6179 }
6180
6181 static bool HasDebugActionsMask(int mask)
6182 {
6183 return ItemBase.m_DebugActionsMask & mask;
6184 }
6185
6186 static void SetDebugActionsMask(int mask)
6187 {
6188 ItemBase.m_DebugActionsMask = mask;
6189 }
6190
6191 static void AddDebugActionsMask(int mask)
6192 {
6193 ItemBase.m_DebugActionsMask |= mask;
6194 }
6195
6196 static void RemoveDebugActionsMask(int mask)
6197 {
6198 ItemBase.m_DebugActionsMask &= ~mask;
6199 }
6200
6201 static void ToggleDebugActionsMask(int mask)
6202 {
6203 if (HasDebugActionsMask(mask))
6204 {
6206 }
6207 else
6208 {
6209 AddDebugActionsMask(mask);
6210 }
6211 }
6212
6213 // -------------------------------------------------------------------------
6214 void SetCEBasedQuantity()
6215 {
6216 if (GetEconomyProfile())
6217 {
6218 float q_max = GetEconomyProfile().GetQuantityMax();
6219 if (q_max > 0)
6220 {
6221 float q_min = GetEconomyProfile().GetQuantityMin();
6222 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
6223
6224 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
6225 {
6226 ComponentEnergyManager comp = GetCompEM();
6227 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
6228 {
6229 comp.SetEnergy0To1(quantity_randomized);
6230 }
6231 }
6232 else if (HasQuantity())
6233 {
6234 SetQuantityNormalized(quantity_randomized, false);
6235 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
6236 }
6237
6238 }
6239 }
6240 }
6241
6243 void LockToParent()
6244 {
6245 EntityAI parent = GetHierarchyParent();
6246
6247 if (parent)
6248 {
6249 InventoryLocation inventory_location_to_lock = new InventoryLocation;
6250 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
6251 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
6252 }
6253 }
6254
6256 void UnlockFromParent()
6257 {
6258 EntityAI parent = GetHierarchyParent();
6259
6260 if (parent)
6261 {
6262 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
6263 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
6264 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
6265 }
6266 }
6267
6268 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
6269 {
6270 /*
6271 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
6272 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
6273 */
6274 ItemBase item2 = ItemBase.Cast(entity2);
6275
6276 if (GetGame().IsClient())
6277 {
6278 if (ScriptInputUserData.CanStoreInputUserData())
6279 {
6280 ScriptInputUserData ctx = new ScriptInputUserData;
6282 ctx.Write(-1);
6283 ItemBase i1 = this; // @NOTE: workaround for correct serialization
6284 ctx.Write(i1);
6285 ctx.Write(item2);
6286 ctx.Write(use_stack_max);
6287 ctx.Write(-1);
6288 ctx.Send();
6289
6290 if (IsCombineAll(item2, use_stack_max))
6291 {
6292 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
6293 }
6294 }
6295 }
6296 else if (!GetGame().IsMultiplayer())
6297 {
6298 CombineItems(item2, use_stack_max);
6299 }
6300 }
6301
6302 bool IsLiquidPresent()
6303 {
6304 return (GetLiquidType() != 0 && HasQuantity());
6305 }
6306
6307 bool IsLiquidContainer()
6308 {
6309 return m_LiquidContainerMask != 0;
6310 }
6311
6313 {
6314 return m_LiquidContainerMask;
6315 }
6316
6317 bool IsBloodContainer()
6318 {
6319 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
6320 return false;
6321 }
6322
6323 bool IsNVG()
6324 {
6325 return false;
6326 }
6327
6330 bool IsExplosive()
6331 {
6332 return false;
6333 }
6334
6336 {
6337 return "";
6338 }
6339
6341
6342 bool IsLightSource()
6343 {
6344 return false;
6345 }
6346
6348 {
6349 return true;
6350 }
6351
6352 //--- ACTION CONDITIONS
6353 //direction
6354 bool IsFacingPlayer(PlayerBase player, string selection)
6355 {
6356 return true;
6357 }
6358
6359 bool IsPlayerInside(PlayerBase player, string selection)
6360 {
6361 return true;
6362 }
6363
6364 override bool CanObstruct()
6365 {
6366 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6367 return !player || !IsPlayerInside(player, "");
6368 }
6369
6370 override bool IsBeingPlaced()
6371 {
6372 return m_IsBeingPlaced;
6373 }
6374
6375 void SetIsBeingPlaced(bool is_being_placed)
6376 {
6377 m_IsBeingPlaced = is_being_placed;
6378 if (!is_being_placed)
6380 SetSynchDirty();
6381 }
6382
6383 //server-side
6384 void OnEndPlacement() {}
6385
6386 override bool IsHologram()
6387 {
6388 return m_IsHologram;
6389 }
6390
6391 bool CanBeDigged()
6392 {
6393 return m_CanBeDigged;
6394 }
6395
6397 {
6398 return 1;
6399 }
6400
6401 bool CanMakeGardenplot()
6402 {
6403 return false;
6404 }
6405
6406 void SetIsHologram(bool is_hologram)
6407 {
6408 m_IsHologram = is_hologram;
6409 SetSynchDirty();
6410 }
6411 /*
6412 protected float GetNutritionalEnergy()
6413 {
6414 Edible_Base edible = Edible_Base.Cast(this);
6415 return edible.GetFoodEnergy();
6416 }
6417
6418 protected float GetNutritionalWaterContent()
6419 {
6420 Edible_Base edible = Edible_Base.Cast(this);
6421 return edible.GetFoodWater();
6422 }
6423
6424 protected float GetNutritionalIndex()
6425 {
6426 Edible_Base edible = Edible_Base.Cast(this);
6427 return edible.GetFoodNutritionalIndex();
6428 }
6429
6430 protected float GetNutritionalFullnessIndex()
6431 {
6432 Edible_Base edible = Edible_Base.Cast(this);
6433 return edible.GetFoodTotalVolume();
6434 }
6435
6436 protected float GetNutritionalToxicity()
6437 {
6438 Edible_Base edible = Edible_Base.Cast(this);
6439 return edible.GetFoodToxicity();
6440
6441 }
6442 */
6443
6444
6445 // -------------------------------------------------------------------------
6446 override void OnMovedInsideCargo(EntityAI container)
6447 {
6448 super.OnMovedInsideCargo(container);
6449
6450 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6451 }
6452
6453 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6454 {
6455 super.EEItemLocationChanged(oldLoc,newLoc);
6456
6457 PlayerBase new_player = null;
6458 PlayerBase old_player = null;
6459
6460 if (newLoc.GetParent())
6461 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
6462
6463 if (oldLoc.GetParent())
6464 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
6465
6466 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
6467 {
6468 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
6469
6470 if (r_index >= 0)
6471 {
6472 InventoryLocation r_il = new InventoryLocation;
6473 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6474
6475 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6476 int r_type = r_il.GetType();
6477 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6478 {
6479 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6480 }
6481 else if (r_type == InventoryLocationType.ATTACHMENT)
6482 {
6483 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6484 }
6485
6486 }
6487 }
6488
6489 if (newLoc.GetType() == InventoryLocationType.HANDS)
6490 {
6491 if (new_player)
6492 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
6493
6494 if (new_player == old_player)
6495 {
6496
6497 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
6498 {
6499 if (oldLoc.GetType() == InventoryLocationType.CARGO)
6500 {
6501 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
6502 {
6503 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6504 }
6505 }
6506 else
6507 {
6508 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6509 }
6510 }
6511
6512 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
6513 {
6514 int type = oldLoc.GetType();
6515 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
6516 {
6517 oldLoc.GetParent().GetOnSetLock().Invoke(this);
6518 }
6519 else if (type == InventoryLocationType.ATTACHMENT)
6520 {
6521 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
6522 }
6523 }
6524 if (!m_OldLocation)
6525 {
6526 m_OldLocation = new InventoryLocation;
6527 }
6528 m_OldLocation.Copy(oldLoc);
6529 }
6530 else
6531 {
6532 if (m_OldLocation)
6533 {
6534 m_OldLocation.Reset();
6535 }
6536 }
6537
6539 }
6540 else
6541 {
6542 if (new_player)
6543 {
6544 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
6545 if (res_index >= 0)
6546 {
6547 InventoryLocation il = new InventoryLocation;
6548 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
6549 ItemBase it = ItemBase.Cast(il.GetItem());
6550 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
6551 int rel_type = il.GetType();
6552 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
6553 {
6554 il.GetParent().GetOnReleaseLock().Invoke(it);
6555 }
6556 else if (rel_type == InventoryLocationType.ATTACHMENT)
6557 {
6558 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
6559 }
6560 //it.GetOnReleaseLock().Invoke(it);
6561 }
6562 }
6563 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
6564 {
6565 //ThrowPhysically(old_player, vector.Zero);
6566 m_ThrowItemOnDrop = false;
6567 }
6568
6569 if (m_OldLocation)
6570 {
6571 m_OldLocation.Reset();
6572 }
6573 }
6574 }
6575
6576 override void EOnContact(IEntity other, Contact extra)
6577 {
6579 {
6580 int liquidType = -1;
6581 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
6582 if (impactSpeed > 0.0)
6583 {
6584 m_ImpactSpeed = impactSpeed;
6585 #ifndef SERVER
6586 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
6587 #else
6588 m_WantPlayImpactSound = true;
6589 SetSynchDirty();
6590 #endif
6591 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
6592 }
6593 }
6594
6595 #ifdef SERVER
6596 if (GetCompEM() && GetCompEM().IsPlugged())
6597 {
6598 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
6599 GetCompEM().UnplugThis();
6600 }
6601 #endif
6602 }
6603
6604 void RefreshPhysics();
6605
6606 override void OnCreatePhysics()
6607 {
6609 }
6610
6611 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6612 {
6613
6614 }
6615 // -------------------------------------------------------------------------
6616 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
6617 {
6618 super.OnItemLocationChanged(old_owner, new_owner);
6619
6620 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
6621 PlayerBase playerNew = PlayerBase.Cast(new_owner);
6622
6623 if (!relatedPlayer && playerNew)
6624 relatedPlayer = playerNew;
6625
6626 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
6627 {
6628 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
6629 if (actionMgr)
6630 {
6631 ActionBase currentAction = actionMgr.GetRunningAction();
6632 if (currentAction)
6633 currentAction.OnItemLocationChanged(this);
6634 }
6635 }
6636
6637 Man ownerPlayerOld = null;
6638 Man ownerPlayerNew = null;
6639
6640 if (old_owner)
6641 {
6642 if (old_owner.IsMan())
6643 {
6644 ownerPlayerOld = Man.Cast(old_owner);
6645 }
6646 else
6647 {
6648 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
6649 }
6650 }
6651 else
6652 {
6653 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
6654 {
6655 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
6656
6657 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
6658 {
6659 GetCompEM().UnplugThis();
6660 }
6661 }
6662 }
6663
6664 if (new_owner)
6665 {
6666 if (new_owner.IsMan())
6667 {
6668 ownerPlayerNew = Man.Cast(new_owner);
6669 }
6670 else
6671 {
6672 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
6673 }
6674 }
6675
6676 if (ownerPlayerOld != ownerPlayerNew)
6677 {
6678 if (ownerPlayerOld)
6679 {
6680 array<EntityAI> subItemsExit = new array<EntityAI>;
6681 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
6682 for (int i = 0; i < subItemsExit.Count(); i++)
6683 {
6684 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
6685 itemExit.OnInventoryExit(ownerPlayerOld);
6686 }
6687 }
6688
6689 if (ownerPlayerNew)
6690 {
6691 array<EntityAI> subItemsEnter = new array<EntityAI>;
6692 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
6693 for (int j = 0; j < subItemsEnter.Count(); j++)
6694 {
6695 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
6696 itemEnter.OnInventoryEnter(ownerPlayerNew);
6697 }
6698 }
6699 }
6700 else if (ownerPlayerNew != null)
6701 {
6702 PlayerBase nplayer;
6703 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
6704 {
6705 array<EntityAI> subItemsUpdate = new array<EntityAI>;
6706 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
6707 for (int k = 0; k < subItemsUpdate.Count(); k++)
6708 {
6709 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
6710 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
6711 }
6712 }
6713 }
6714
6715 if (old_owner)
6716 old_owner.OnChildItemRemoved(this);
6717 if (new_owner)
6718 new_owner.OnChildItemReceived(this);
6719 }
6720
6721 // -------------------------------------------------------------------------------
6722 override void EEDelete(EntityAI parent)
6723 {
6724 super.EEDelete(parent);
6725 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
6726 if (player)
6727 {
6728 OnInventoryExit(player);
6729
6730 if (player.IsAlive())
6731 {
6732 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6733 if (r_index >= 0)
6734 {
6735 InventoryLocation r_il = new InventoryLocation;
6736 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6737
6738 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6739 int r_type = r_il.GetType();
6740 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6741 {
6742 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6743 }
6744 else if (r_type == InventoryLocationType.ATTACHMENT)
6745 {
6746 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6747 }
6748
6749 }
6750
6751 player.RemoveQuickBarEntityShortcut(this);
6752 }
6753 }
6754 }
6755 // -------------------------------------------------------------------------------
6756 override void EEKilled(Object killer)
6757 {
6758 super.EEKilled(killer);
6759
6761 if (killer && killer.IsFireplace() && CanExplodeInFire())
6762 {
6763 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
6764 {
6765 if (IsMagazine())
6766 {
6767 if (Magazine.Cast(this).GetAmmoCount() > 0)
6768 {
6769 ExplodeAmmo();
6770 }
6771 }
6772 else
6773 {
6774 Explode(DamageType.EXPLOSION);
6775 }
6776 }
6777 }
6778 }
6779
6780 override void OnWasAttached(EntityAI parent, int slot_id)
6781 {
6782 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6783
6784 super.OnWasAttached(parent, slot_id);
6785
6786 if (HasQuantity())
6787 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6788
6789 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
6790 }
6791
6792 override void OnWasDetached(EntityAI parent, int slot_id)
6793 {
6794 super.OnWasDetached(parent, slot_id);
6795
6796 if (HasQuantity())
6797 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6798 }
6799
6800 override string ChangeIntoOnAttach(string slot)
6801 {
6802 int idx;
6803 TStringArray inventory_slots = new TStringArray;
6804 TStringArray attach_types = new TStringArray;
6805
6806 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
6807 if (inventory_slots.Count() < 1) //is string
6808 {
6809 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
6810 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
6811 }
6812 else //is array
6813 {
6814 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
6815 }
6816
6817 idx = inventory_slots.Find(slot);
6818 if (idx < 0)
6819 return "";
6820
6821 return attach_types.Get(idx);
6822 }
6823
6824 override string ChangeIntoOnDetach()
6825 {
6826 int idx = -1;
6827 string slot;
6828
6829 TStringArray inventory_slots = new TStringArray;
6830 TStringArray detach_types = new TStringArray;
6831
6832 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
6833 if (inventory_slots.Count() < 1) //is string
6834 {
6835 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
6836 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
6837 }
6838 else //is array
6839 {
6840 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
6841 if (detach_types.Count() < 1)
6842 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
6843 }
6844
6845 for (int i = 0; i < inventory_slots.Count(); i++)
6846 {
6847 slot = inventory_slots.Get(i);
6848 }
6849
6850 if (slot != "")
6851 {
6852 if (detach_types.Count() == 1)
6853 idx = 0;
6854 else
6855 idx = inventory_slots.Find(slot);
6856 }
6857 if (idx < 0)
6858 return "";
6859
6860 return detach_types.Get(idx);
6861 }
6862
6863 void ExplodeAmmo()
6864 {
6865 //timer
6866 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
6867
6868 //min/max time
6869 float min_time = 1;
6870 float max_time = 3;
6871 float delay = Math.RandomFloat(min_time, max_time);
6872
6873 explode_timer.Run(delay, this, "DoAmmoExplosion");
6874 }
6875
6876 void DoAmmoExplosion()
6877 {
6878 Magazine magazine = Magazine.Cast(this);
6879 int pop_sounds_count = 6;
6880 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
6881
6882 //play sound
6883 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
6884 string sound_name = pop_sounds[ sound_idx ];
6885 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
6886
6887 //remove ammo count
6888 magazine.ServerAddAmmoCount(-1);
6889
6890 //if condition then repeat -> ExplodeAmmo
6891 float min_temp_to_explode = 100; //min temperature for item to explode
6892
6893 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
6894 {
6895 ExplodeAmmo();
6896 }
6897 }
6898
6899 // -------------------------------------------------------------------------------
6900 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
6901 {
6902 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
6903
6904 const int CHANCE_DAMAGE_CARGO = 4;
6905 const int CHANCE_DAMAGE_ATTACHMENT = 1;
6906 const int CHANCE_DAMAGE_NOTHING = 2;
6907
6908 if (IsClothing() || IsContainer() || IsItemTent())
6909 {
6910 float dmg = damageResult.GetDamage("","Health") * -0.5;
6911 int chances;
6912 int rnd;
6913
6914 if (GetInventory().GetCargo())
6915 {
6916 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
6917 rnd = Math.RandomInt(0,chances);
6918
6919 if (rnd < CHANCE_DAMAGE_CARGO)
6920 {
6921 DamageItemInCargo(dmg);
6922 }
6923 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
6924 {
6926 }
6927 }
6928 else
6929 {
6930 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
6931 rnd = Math.RandomInt(0,chances);
6932
6933 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
6934 {
6936 }
6937 }
6938 }
6939 }
6940
6941 bool DamageItemInCargo(float damage)
6942 {
6943 if (GetInventory().GetCargo())
6944 {
6945 int item_count = GetInventory().GetCargo().GetItemCount();
6946 if (item_count > 0)
6947 {
6948 int random_pick = Math.RandomInt(0, item_count);
6949 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
6950 if (!item.IsExplosive())
6951 {
6952 item.AddHealth("","",damage);
6953 return true;
6954 }
6955 }
6956 }
6957 return false;
6958 }
6959
6960 bool DamageItemAttachments(float damage)
6961 {
6962 int attachment_count = GetInventory().AttachmentCount();
6963 if (attachment_count > 0)
6964 {
6965 int random_pick = Math.RandomInt(0, attachment_count);
6966 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
6967 if (!attachment.IsExplosive())
6968 {
6969 attachment.AddHealth("","",damage);
6970 return true;
6971 }
6972 }
6973 return false;
6974 }
6975
6976 override bool IsSplitable()
6977 {
6978 return m_CanThisBeSplit;
6979 }
6980 //----------------
6981 override bool CanBeSplit()
6982 {
6983 if (IsSplitable() && (GetQuantity() > 1))
6984 return GetInventory().CanRemoveEntity();
6985
6986 return false;
6987 }
6988
6989 protected bool ShouldSplitQuantity(float quantity)
6990 {
6991 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
6992 if (!IsSplitable())
6993 return false;
6994
6995 // nothing to split?
6996 if (GetQuantity() <= 1)
6997 return false;
6998
6999 // check if we should re-use the item instead of creating a new copy?
7000 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
7001 int delta = GetQuantity() - quantity;
7002 if (delta == 0)
7003 return false;
7004
7005 // valid to split
7006 return true;
7007 }
7008
7009 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
7010 {
7011 if (GetGame().IsClient())
7012 {
7013 if (ScriptInputUserData.CanStoreInputUserData())
7014 {
7015 ScriptInputUserData ctx = new ScriptInputUserData;
7017 ctx.Write(1);
7018 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7019 ctx.Write(i1);
7020 ctx.Write(destination_entity);
7021 ctx.Write(true);
7022 ctx.Write(slot_id);
7023 ctx.Send();
7024 }
7025 }
7026 else if (!GetGame().IsMultiplayer())
7027 {
7028 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
7029 }
7030 }
7031
7032 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
7033 {
7034 float split_quantity_new;
7035 ItemBase new_item;
7036 float quantity = GetQuantity();
7037 float stack_max = GetTargetQuantityMax(slot_id);
7038 InventoryLocation loc = new InventoryLocation;
7039
7040 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7041 {
7042 if (stack_max <= GetQuantity())
7043 split_quantity_new = stack_max;
7044 else
7045 split_quantity_new = GetQuantity();
7046
7047 if (ShouldSplitQuantity(split_quantity_new))
7048 {
7049 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7050 if (new_item)
7051 {
7052 new_item.SetResultOfSplit(true);
7053 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7054 AddQuantity(-split_quantity_new, false, true);
7055 new_item.SetQuantity(split_quantity_new, false, true);
7056 }
7057 }
7058 }
7059 else if (destination_entity && slot_id == -1)
7060 {
7061 if (quantity > stack_max)
7062 split_quantity_new = stack_max;
7063 else
7064 split_quantity_new = quantity;
7065
7066 if (ShouldSplitQuantity(split_quantity_new))
7067 {
7068 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7069 {
7070 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7071 new_item = ItemBase.Cast(o);
7072 }
7073
7074 if (new_item)
7075 {
7076 new_item.SetResultOfSplit(true);
7077 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7078 AddQuantity(-split_quantity_new, false, true);
7079 new_item.SetQuantity(split_quantity_new, false, true);
7080 }
7081 }
7082 }
7083 else
7084 {
7085 if (stack_max != 0)
7086 {
7087 if (stack_max < GetQuantity())
7088 {
7089 split_quantity_new = GetQuantity() - stack_max;
7090 }
7091
7092 if (split_quantity_new == 0)
7093 {
7094 if (!GetGame().IsMultiplayer())
7095 player.PhysicalPredictiveDropItem(this);
7096 else
7097 player.ServerDropEntity(this);
7098 return;
7099 }
7100
7101 if (ShouldSplitQuantity(split_quantity_new))
7102 {
7103 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7104
7105 if (new_item)
7106 {
7107 new_item.SetResultOfSplit(true);
7108 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7109 SetQuantity(split_quantity_new, false, true);
7110 new_item.SetQuantity(stack_max, false, true);
7111 new_item.PlaceOnSurface();
7112 }
7113 }
7114 }
7115 }
7116 }
7117
7118 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
7119 {
7120 float split_quantity_new;
7121 ItemBase new_item;
7122 float quantity = GetQuantity();
7123 float stack_max = GetTargetQuantityMax(slot_id);
7124 InventoryLocation loc = new InventoryLocation;
7125
7126 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7127 {
7128 if (stack_max <= GetQuantity())
7129 split_quantity_new = stack_max;
7130 else
7131 split_quantity_new = GetQuantity();
7132
7133 if (ShouldSplitQuantity(split_quantity_new))
7134 {
7135 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7136 if (new_item)
7137 {
7138 new_item.SetResultOfSplit(true);
7139 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7140 AddQuantity(-split_quantity_new, false, true);
7141 new_item.SetQuantity(split_quantity_new, false, true);
7142 }
7143 }
7144 }
7145 else if (destination_entity && slot_id == -1)
7146 {
7147 if (quantity > stack_max)
7148 split_quantity_new = stack_max;
7149 else
7150 split_quantity_new = quantity;
7151
7152 if (ShouldSplitQuantity(split_quantity_new))
7153 {
7154 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7155 {
7156 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7157 new_item = ItemBase.Cast(o);
7158 }
7159
7160 if (new_item)
7161 {
7162 new_item.SetResultOfSplit(true);
7163 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7164 AddQuantity(-split_quantity_new, false, true);
7165 new_item.SetQuantity(split_quantity_new, false, true);
7166 }
7167 }
7168 }
7169 else
7170 {
7171 if (stack_max != 0)
7172 {
7173 if (stack_max < GetQuantity())
7174 {
7175 split_quantity_new = GetQuantity() - stack_max;
7176 }
7177
7178 if (ShouldSplitQuantity(split_quantity_new))
7179 {
7180 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7181
7182 if (new_item)
7183 {
7184 new_item.SetResultOfSplit(true);
7185 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7186 SetQuantity(split_quantity_new, false, true);
7187 new_item.SetQuantity(stack_max, false, true);
7188 new_item.PlaceOnSurface();
7189 }
7190 }
7191 }
7192 }
7193 }
7194
7195 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
7196 {
7197 if (GetGame().IsClient())
7198 {
7199 if (ScriptInputUserData.CanStoreInputUserData())
7200 {
7201 ScriptInputUserData ctx = new ScriptInputUserData;
7203 ctx.Write(4);
7204 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7205 ctx.Write(thiz);
7206 dst.WriteToContext(ctx);
7207 ctx.Send();
7208 }
7209 }
7210 else if (!GetGame().IsMultiplayer())
7211 {
7213 }
7214 }
7215
7216 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
7217 {
7218 if (GetGame().IsClient())
7219 {
7220 if (ScriptInputUserData.CanStoreInputUserData())
7221 {
7222 ScriptInputUserData ctx = new ScriptInputUserData;
7224 ctx.Write(2);
7225 ItemBase dummy = this; // @NOTE: workaround for correct serialization
7226 ctx.Write(dummy);
7227 ctx.Write(destination_entity);
7228 ctx.Write(true);
7229 ctx.Write(idx);
7230 ctx.Write(row);
7231 ctx.Write(col);
7232 ctx.Send();
7233 }
7234 }
7235 else if (!GetGame().IsMultiplayer())
7236 {
7237 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
7238 }
7239 }
7240
7241 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
7242 {
7244 }
7245
7246 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
7247 {
7248 float quantity = GetQuantity();
7249 float split_quantity_new;
7250 ItemBase new_item;
7251 if (dst.IsValid())
7252 {
7253 int slot_id = dst.GetSlot();
7254 float stack_max = GetTargetQuantityMax(slot_id);
7255
7256 if (quantity > stack_max)
7257 split_quantity_new = stack_max;
7258 else
7259 split_quantity_new = quantity;
7260
7261 if (ShouldSplitQuantity(split_quantity_new))
7262 {
7263 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7264
7265 if (new_item)
7266 {
7267 new_item.SetResultOfSplit(true);
7268 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7269 AddQuantity(-split_quantity_new, false, true);
7270 new_item.SetQuantity(split_quantity_new, false, true);
7271 }
7272
7273 return new_item;
7274 }
7275 }
7276
7277 return null;
7278 }
7279
7280 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
7281 {
7282 float quantity = GetQuantity();
7283 float split_quantity_new;
7284 ItemBase new_item;
7285 if (destination_entity)
7286 {
7287 float stackable = GetTargetQuantityMax();
7288 if (quantity > stackable)
7289 split_quantity_new = stackable;
7290 else
7291 split_quantity_new = quantity;
7292
7293 if (ShouldSplitQuantity(split_quantity_new))
7294 {
7295 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
7296 if (new_item)
7297 {
7298 new_item.SetResultOfSplit(true);
7299 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7300 AddQuantity(-split_quantity_new, false, true);
7301 new_item.SetQuantity(split_quantity_new, false, true);
7302 }
7303 }
7304 }
7305 }
7306
7307 void SplitIntoStackMaxHandsClient(PlayerBase player)
7308 {
7309 if (GetGame().IsClient())
7310 {
7311 if (ScriptInputUserData.CanStoreInputUserData())
7312 {
7313 ScriptInputUserData ctx = new ScriptInputUserData;
7315 ctx.Write(3);
7316 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7317 ctx.Write(i1);
7318 ItemBase destination_entity = this;
7319 ctx.Write(destination_entity);
7320 ctx.Write(true);
7321 ctx.Write(0);
7322 ctx.Send();
7323 }
7324 }
7325 else if (!GetGame().IsMultiplayer())
7326 {
7327 SplitIntoStackMaxHands(player);
7328 }
7329 }
7330
7331 void SplitIntoStackMaxHands(PlayerBase player)
7332 {
7333 float quantity = GetQuantity();
7334 float split_quantity_new;
7335 ref ItemBase new_item;
7336 if (player)
7337 {
7338 float stackable = GetTargetQuantityMax();
7339 if (quantity > stackable)
7340 split_quantity_new = stackable;
7341 else
7342 split_quantity_new = quantity;
7343
7344 if (ShouldSplitQuantity(split_quantity_new))
7345 {
7346 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
7347 new_item = ItemBase.Cast(in_hands);
7348 if (new_item)
7349 {
7350 new_item.SetResultOfSplit(true);
7351 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7352 AddQuantity(-split_quantity_new, false, true);
7353 new_item.SetQuantity(split_quantity_new, false, true);
7354 }
7355 }
7356 }
7357 }
7358
7359 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
7360 {
7361 float quantity = GetQuantity();
7362 float split_quantity_new = Math.Floor(quantity * 0.5);
7363
7364 if (!ShouldSplitQuantity(split_quantity_new))
7365 return;
7366
7367 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7368
7369 if (new_item)
7370 {
7371 if (new_item.GetQuantityMax() < split_quantity_new)
7372 {
7373 split_quantity_new = new_item.GetQuantityMax();
7374 }
7375
7376 new_item.SetResultOfSplit(true);
7377 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7378
7379 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7380 {
7381 AddQuantity(-1, false, true);
7382 new_item.SetQuantity(1, false, true);
7383 }
7384 else
7385 {
7386 AddQuantity(-split_quantity_new, false, true);
7387 new_item.SetQuantity(split_quantity_new, false, true);
7388 }
7389 }
7390 }
7391
7392 void SplitItem(PlayerBase player)
7393 {
7394 float quantity = GetQuantity();
7395 float split_quantity_new = Math.Floor(quantity / 2);
7396
7397 if (!ShouldSplitQuantity(split_quantity_new))
7398 return;
7399
7400 InventoryLocation invloc = new InventoryLocation;
7401 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
7402
7403 ItemBase new_item;
7404 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
7405
7406 if (new_item)
7407 {
7408 if (new_item.GetQuantityMax() < split_quantity_new)
7409 {
7410 split_quantity_new = new_item.GetQuantityMax();
7411 }
7412 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7413 {
7414 AddQuantity(-1, false, true);
7415 new_item.SetQuantity(1, false, true);
7416 }
7417 else if (split_quantity_new > 1)
7418 {
7419 AddQuantity(-split_quantity_new, false, true);
7420 new_item.SetQuantity(split_quantity_new, false, true);
7421 }
7422 }
7423 }
7424
7426 void OnQuantityChanged(float delta)
7427 {
7428 SetWeightDirty();
7429 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
7430
7431 if (parent)
7432 parent.OnAttachmentQuantityChangedEx(this, delta);
7433
7434 if (IsLiquidContainer())
7435 {
7436 if (GetQuantityNormalized() <= 0.0)
7437 {
7439 }
7440 else if (GetLiquidType() == LIQUID_NONE)
7441 {
7442 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
7444 }
7445 }
7446
7447 }
7448
7451 {
7452 // insert code here
7453 }
7454
7456 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
7457 {
7459 }
7460
7461 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
7462 {
7463 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
7464
7465 if (GetGame().IsServer())
7466 {
7467 if (newLevel == GameConstants.STATE_RUINED)
7468 {
7470 EntityAI parent = GetHierarchyParent();
7471 if (parent && parent.IsFireplace())
7472 {
7473 CargoBase cargo = GetInventory().GetCargo();
7474 if (cargo)
7475 {
7476 for (int i = 0; i < cargo.GetItemCount(); ++i)
7477 {
7478 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
7479 }
7480 }
7481 }
7482 }
7483
7484 if (IsResultOfSplit())
7485 {
7486 // reset the splitting result flag, return to normal item behavior
7487 SetResultOfSplit(false);
7488 return;
7489 }
7490
7491 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
7492 {
7493 SetCleanness(0);//unclean the item upon damage dealt
7494 }
7495 }
7496 }
7497
7498 // just the split? TODO: verify
7499 override void OnRightClick()
7500 {
7501 super.OnRightClick();
7502
7503 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
7504 {
7505 if (GetGame().IsClient())
7506 {
7507 if (ScriptInputUserData.CanStoreInputUserData())
7508 {
7509 EntityAI root = GetHierarchyRoot();
7510 Man playerOwner = GetHierarchyRootPlayer();
7511 InventoryLocation dst = new InventoryLocation;
7512
7513 // 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
7514 if (!playerOwner && root && root == this)
7515 {
7517 }
7518 else
7519 {
7520 // 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
7521 GetInventory().GetCurrentInventoryLocation(dst);
7522 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
7523 {
7524 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7525 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
7526 {
7528 }
7529 else
7530 {
7531 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
7532 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
7533 this shouldnt cause issues within this scope*/
7534 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
7535 {
7537 }
7538 else
7539 {
7540 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
7541 }
7542 }
7543 }
7544 }
7545
7546 ScriptInputUserData ctx = new ScriptInputUserData;
7548 ctx.Write(4);
7549 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7550 ctx.Write(thiz);
7551 dst.WriteToContext(ctx);
7552 ctx.Write(true); // dummy
7553 ctx.Send();
7554 }
7555 }
7556 else if (!GetGame().IsMultiplayer())
7557 {
7558 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
7559 }
7560 }
7561 }
7562
7563 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
7564 {
7565 if (root)
7566 {
7567 vector m4[4];
7568 root.GetTransform(m4);
7569 dst.SetGround(this, m4);
7570 }
7571 else
7572 {
7573 GetInventory().GetCurrentInventoryLocation(dst);
7574 }
7575 }
7576
7577 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
7578 {
7579 //TODO: delete check zero quantity check after fix double posts hands fsm events
7580 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
7581 return false;
7582
7583 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
7584 return false;
7585
7586 //can_this_be_combined = ConfigGetBool("canBeSplit");
7588 return false;
7589
7590
7591 Magazine mag = Magazine.Cast(this);
7592 if (mag)
7593 {
7594 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
7595 return false;
7596
7597 if (stack_max_limit)
7598 {
7599 Magazine other_mag = Magazine.Cast(other_item);
7600 if (other_item)
7601 {
7602 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
7603 return false;
7604 }
7605
7606 }
7607 }
7608 else
7609 {
7610 //TODO: delete check zero quantity check after fix double posts hands fsm events
7611 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
7612 return false;
7613
7614 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
7615 return false;
7616 }
7617
7618 PlayerBase player = null;
7619 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
7620 {
7621 if (player.GetInventory().HasAttachment(this))
7622 return false;
7623
7624 if (player.IsItemsToDelete())
7625 return false;
7626 }
7627
7628 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
7629 return false;
7630
7631 int slotID;
7632 string slotName;
7633 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
7634 return false;
7635
7636 return true;
7637 }
7638
7639 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
7640 {
7641 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
7642 }
7643
7644 bool IsResultOfSplit()
7645 {
7646 return m_IsResultOfSplit;
7647 }
7648
7649 void SetResultOfSplit(bool value)
7650 {
7651 m_IsResultOfSplit = value;
7652 }
7653
7654 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
7655 {
7656 return ComputeQuantityUsedEx(other_item, use_stack_max);
7657 }
7658
7659 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
7660 {
7661 float other_item_quantity = other_item.GetQuantity();
7662 float this_free_space;
7663
7664 float stack_max = GetQuantityMax();
7665
7666 this_free_space = stack_max - GetQuantity();
7667
7668 if (other_item_quantity > this_free_space)
7669 {
7670 return this_free_space;
7671 }
7672 else
7673 {
7674 return other_item_quantity;
7675 }
7676 }
7677
7678 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
7679 {
7680 CombineItems(ItemBase.Cast(entity2),use_stack_max);
7681 }
7682
7683 void CombineItems(ItemBase other_item, bool use_stack_max = true)
7684 {
7685 if (!CanBeCombined(other_item, false))
7686 return;
7687
7688 if (!IsMagazine() && other_item)
7689 {
7690 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
7691 if (quantity_used != 0)
7692 {
7693 float hp1 = GetHealth01("","");
7694 float hp2 = other_item.GetHealth01("","");
7695 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
7696 hpResult = hpResult / (GetQuantity() + quantity_used);
7697
7698 hpResult *= GetMaxHealth();
7699 Math.Round(hpResult);
7700 SetHealth("", "Health", hpResult);
7701
7702 AddQuantity(quantity_used);
7703 other_item.AddQuantity(-quantity_used);
7704 }
7705 }
7706 OnCombine(other_item);
7707 }
7708
7709 void OnCombine(ItemBase other_item)
7710 {
7711 #ifdef SERVER
7712 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
7713 GetHierarchyParent().IncreaseLifetimeUp();
7714 #endif
7715 };
7716
7717 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
7718 {
7719 PlayerBase p = PlayerBase.Cast(player);
7720
7721 array<int> recipesIds = p.m_Recipes;
7722 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
7723 if (moduleRecipesManager)
7724 {
7725 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
7726 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
7727 }
7728
7729 for (int i = 0;i < recipesIds.Count(); i++)
7730 {
7731 int key = recipesIds.Get(i);
7732 string recipeName = moduleRecipesManager.GetRecipeName(key);
7733 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
7734 }
7735 }
7736
7737 // -------------------------------------------------------------------------
7738 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
7739 {
7740 super.GetDebugActions(outputList);
7741
7742 //quantity
7743 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
7744 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
7745 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
7746 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
7747 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7748
7749 //health
7750 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
7751 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
7752 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
7753 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7754 //temperature
7755 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
7756 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
7757 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
7758 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7759
7760 //wet
7761 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
7762 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
7763 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7764
7765 //liquidtype
7766 if (IsLiquidContainer())
7767 {
7768 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
7769 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
7770 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7771 }
7772
7773 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
7774 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7775
7776 // watch
7777 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
7778 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
7779 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7780
7781 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
7782
7783 InventoryLocation loc = new InventoryLocation();
7784 GetInventory().GetCurrentInventoryLocation(loc);
7785 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
7786 {
7787 if (Gizmo_IsSupported())
7788 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
7789 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
7790 }
7791
7792 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7793 }
7794
7795 // -------------------------------------------------------------------------
7796 // -------------------------------------------------------------------------
7797 // -------------------------------------------------------------------------
7798 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
7799 {
7800 super.OnAction(action_id, player, ctx);
7801
7802 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
7803 {
7804 switch (action_id)
7805 {
7806 case EActions.GIZMO_OBJECT:
7807 GetGame().GizmoSelectObject(this);
7808 return true;
7809 case EActions.GIZMO_PHYSICS:
7810 GetGame().GizmoSelectPhysics(GetPhysics());
7811 return true;
7812 }
7813 }
7814
7815 if (GetGame().IsServer())
7816 {
7817 switch (action_id)
7818 {
7819 case EActions.DELETE:
7820 Delete();
7821 return true;
7822 }
7823 }
7824
7825 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
7826 {
7827 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
7828 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
7829 PlayerBase p = PlayerBase.Cast(player);
7830 if (EActions.RECIPES_RANGE_START < 1000)
7831 {
7832 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
7833 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
7834 }
7835 }
7836 #ifndef SERVER
7837 else if (action_id == EActions.WATCH_PLAYER)
7838 {
7839 PluginDeveloper.SetDeveloperItemClientEx(player);
7840 }
7841 #endif
7842 if (GetGame().IsServer())
7843 {
7844 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
7845 {
7846 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
7847 OnDebugButtonPressServer(id + 1);
7848 }
7849
7850 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
7851 {
7852 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
7853 InsertAgent(agent_id,100);
7854 }
7855
7856 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
7857 {
7858 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
7859 RemoveAgent(agent_id2);
7860 }
7861
7862 else if (action_id == EActions.ADD_QUANTITY)
7863 {
7864 if (IsMagazine())
7865 {
7866 Magazine mag = Magazine.Cast(this);
7867 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
7868 }
7869 else
7870 {
7871 AddQuantity(GetQuantityMax() * 0.2);
7872 }
7873
7874 if (m_EM)
7875 {
7876 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
7877 }
7878 //PrintVariables();
7879 }
7880
7881 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
7882 {
7883 if (IsMagazine())
7884 {
7885 Magazine mag2 = Magazine.Cast(this);
7886 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
7887 }
7888 else
7889 {
7890 AddQuantity(- GetQuantityMax() * 0.2);
7891 }
7892 if (m_EM)
7893 {
7894 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
7895 }
7896 //PrintVariables();
7897 }
7898
7899 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
7900 {
7901 SetQuantity(0);
7902
7903 if (m_EM)
7904 {
7905 m_EM.SetEnergy(0);
7906 }
7907 }
7908
7909 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
7910 {
7912
7913 if (m_EM)
7914 {
7915 m_EM.SetEnergy(m_EM.GetEnergyMax());
7916 }
7917 }
7918
7919 else if (action_id == EActions.ADD_HEALTH)
7920 {
7921 AddHealth("","",GetMaxHealth("","Health")/5);
7922 }
7923 else if (action_id == EActions.REMOVE_HEALTH)
7924 {
7925 AddHealth("","",-GetMaxHealth("","Health")/5);
7926 }
7927 else if (action_id == EActions.DESTROY_HEALTH)
7928 {
7929 SetHealth01("","",0);
7930 }
7931 else if (action_id == EActions.WATCH_ITEM)
7932 {
7934 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
7935 #ifdef DEVELOPER
7936 SetDebugDeveloper_item(this);
7937 #endif
7938 }
7939
7940 else if (action_id == EActions.ADD_TEMPERATURE)
7941 {
7942 AddTemperature(20);
7943 //PrintVariables();
7944 }
7945
7946 else if (action_id == EActions.REMOVE_TEMPERATURE)
7947 {
7948 AddTemperature(-20);
7949 //PrintVariables();
7950 }
7951
7952 else if (action_id == EActions.FLIP_FROZEN)
7953 {
7954 SetFrozen(!GetIsFrozen());
7955 //PrintVariables();
7956 }
7957
7958 else if (action_id == EActions.ADD_WETNESS)
7959 {
7960 AddWet(GetWetMax()/5);
7961 //PrintVariables();
7962 }
7963
7964 else if (action_id == EActions.REMOVE_WETNESS)
7965 {
7966 AddWet(-GetWetMax()/5);
7967 //PrintVariables();
7968 }
7969
7970 else if (action_id == EActions.LIQUIDTYPE_UP)
7971 {
7972 int curr_type = GetLiquidType();
7973 SetLiquidType(curr_type * 2);
7974 //AddWet(1);
7975 //PrintVariables();
7976 }
7977
7978 else if (action_id == EActions.LIQUIDTYPE_DOWN)
7979 {
7980 int curr_type2 = GetLiquidType();
7981 SetLiquidType(curr_type2 / 2);
7982 }
7983
7984 else if (action_id == EActions.MAKE_SPECIAL)
7985 {
7986 auto debugParams = DebugSpawnParams.WithPlayer(player);
7987 OnDebugSpawnEx(debugParams);
7988 }
7989
7990 }
7991
7992
7993 return false;
7994 }
7995
7996 // -------------------------------------------------------------------------
7997
7998
8001 void OnActivatedByTripWire();
8002
8004 void OnActivatedByItem(notnull ItemBase item);
8005
8006 //----------------------------------------------------------------
8007 //returns true if item is able to explode when put in fire
8008 bool CanExplodeInFire()
8009 {
8010 return false;
8011 }
8012
8013 //----------------------------------------------------------------
8014 bool CanEat()
8015 {
8016 return true;
8017 }
8018
8019 //----------------------------------------------------------------
8020 override bool IsIgnoredByConstruction()
8021 {
8022 return true;
8023 }
8024
8025 //----------------------------------------------------------------
8026 //has FoodStages in config?
8027 bool HasFoodStage()
8028 {
8029 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
8030 return GetGame().ConfigIsExisting(config_path);
8031 }
8032
8034 FoodStage GetFoodStage()
8035 {
8036 return null;
8037 }
8038
8039 bool CanBeCooked()
8040 {
8041 return false;
8042 }
8043
8044 bool CanBeCookedOnStick()
8045 {
8046 return false;
8047 }
8048
8050 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
8052
8053 //----------------------------------------------------------------
8054 bool CanRepair(ItemBase item_repair_kit)
8055 {
8056 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8057 return module_repairing.CanRepair(this, item_repair_kit);
8058 }
8059
8060 //----------------------------------------------------------------
8061 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
8062 {
8063 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8064 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
8065 }
8066
8067 //----------------------------------------------------------------
8068 int GetItemSize()
8069 {
8070 /*
8071 vector v_size = this.ConfigGetVector("itemSize");
8072 int v_size_x = v_size[0];
8073 int v_size_y = v_size[1];
8074 int size = v_size_x * v_size_y;
8075 return size;
8076 */
8077
8078 return 1;
8079 }
8080
8081 //----------------------------------------------------------------
8082 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8083 bool CanBeMovedOverride()
8084 {
8085 return m_CanBeMovedOverride;
8086 }
8087
8088 //----------------------------------------------------------------
8089 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8090 void SetCanBeMovedOverride(bool setting)
8091 {
8092 m_CanBeMovedOverride = setting;
8093 }
8094
8095 //----------------------------------------------------------------
8103 void MessageToOwnerStatus(string text)
8104 {
8105 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8106
8107 if (player)
8108 {
8109 player.MessageStatus(text);
8110 }
8111 }
8112
8113 //----------------------------------------------------------------
8121 void MessageToOwnerAction(string text)
8122 {
8123 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8124
8125 if (player)
8126 {
8127 player.MessageAction(text);
8128 }
8129 }
8130
8131 //----------------------------------------------------------------
8139 void MessageToOwnerFriendly(string text)
8140 {
8141 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8142
8143 if (player)
8144 {
8145 player.MessageFriendly(text);
8146 }
8147 }
8148
8149 //----------------------------------------------------------------
8157 void MessageToOwnerImportant(string text)
8158 {
8159 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8160
8161 if (player)
8162 {
8163 player.MessageImportant(text);
8164 }
8165 }
8166
8167 override bool IsItemBase()
8168 {
8169 return true;
8170 }
8171
8172 // Checks if item is of questioned kind
8173 override bool KindOf(string tag)
8174 {
8175 bool found = false;
8176 string item_name = this.GetType();
8177 ref TStringArray item_tag_array = new TStringArray;
8178 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
8179
8180 int array_size = item_tag_array.Count();
8181 for (int i = 0; i < array_size; i++)
8182 {
8183 if (item_tag_array.Get(i) == tag)
8184 {
8185 found = true;
8186 break;
8187 }
8188 }
8189 return found;
8190 }
8191
8192
8193 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
8194 {
8195 //Debug.Log("OnRPC called");
8196 super.OnRPC(sender, rpc_type,ctx);
8197
8198 //Play soundset for attachment locking (ActionLockAttachment.c)
8199 switch (rpc_type)
8200 {
8201 #ifndef SERVER
8202 case ERPCs.RPC_SOUND_LOCK_ATTACH:
8203 Param2<bool, string> p = new Param2<bool, string>(false, "");
8204
8205 if (!ctx.Read(p))
8206 return;
8207
8208 bool play = p.param1;
8209 string soundSet = p.param2;
8210
8211 if (play)
8212 {
8213 if (m_LockingSound)
8214 {
8216 {
8217 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8218 }
8219 }
8220 else
8221 {
8222 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8223 }
8224 }
8225 else
8226 {
8227 SEffectManager.DestroyEffect(m_LockingSound);
8228 }
8229
8230 break;
8231 #endif
8232
8233 }
8234
8235 if (GetWrittenNoteData())
8236 {
8237 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
8238 }
8239 }
8240
8241 //-----------------------------
8242 // VARIABLE MANIPULATION SYSTEM
8243 //-----------------------------
8244 int NameToID(string name)
8245 {
8246 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8247 return plugin.GetID(name);
8248 }
8249
8250 string IDToName(int id)
8251 {
8252 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8253 return plugin.GetName(id);
8254 }
8255
8257 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
8258 {
8259 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
8260 //read the flags
8261 int varFlags;
8262 if (!ctx.Read(varFlags))
8263 return;
8264
8265 if (varFlags & ItemVariableFlags.FLOAT)
8266 {
8267 ReadVarsFromCTX(ctx);
8268 }
8269 }
8270
8271 override void SerializeNumericalVars(array<float> floats_out)
8272 {
8273 //some variables handled on EntityAI level already!
8274 super.SerializeNumericalVars(floats_out);
8275
8276 // the order of serialization must be the same as the order of de-serialization
8277 //--------------------------------------------
8278 if (IsVariableSet(VARIABLE_QUANTITY))
8279 {
8280 floats_out.Insert(m_VarQuantity);
8281 }
8282 //--------------------------------------------
8283 if (IsVariableSet(VARIABLE_WET))
8284 {
8285 floats_out.Insert(m_VarWet);
8286 }
8287 //--------------------------------------------
8288 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8289 {
8290 floats_out.Insert(m_VarLiquidType);
8291 }
8292 //--------------------------------------------
8293 if (IsVariableSet(VARIABLE_COLOR))
8294 {
8295 floats_out.Insert(m_ColorComponentR);
8296 floats_out.Insert(m_ColorComponentG);
8297 floats_out.Insert(m_ColorComponentB);
8298 floats_out.Insert(m_ColorComponentA);
8299 }
8300 //--------------------------------------------
8301 if (IsVariableSet(VARIABLE_CLEANNESS))
8302 {
8303 floats_out.Insert(m_Cleanness);
8304 }
8305 }
8306
8307 override void DeSerializeNumericalVars(array<float> floats)
8308 {
8309 //some variables handled on EntityAI level already!
8310 super.DeSerializeNumericalVars(floats);
8311
8312 // the order of serialization must be the same as the order of de-serialization
8313 int index = 0;
8314 int mask = Math.Round(floats.Get(index));
8315
8316 index++;
8317 //--------------------------------------------
8318 if (mask & VARIABLE_QUANTITY)
8319 {
8320 if (m_IsStoreLoad)
8321 {
8322 SetStoreLoadedQuantity(floats.Get(index));
8323 }
8324 else
8325 {
8326 float quantity = floats.Get(index);
8327 SetQuantity(quantity, true, false, false, false);
8328 }
8329 index++;
8330 }
8331 //--------------------------------------------
8332 if (mask & VARIABLE_WET)
8333 {
8334 float wet = floats.Get(index);
8335 SetWet(wet);
8336 index++;
8337 }
8338 //--------------------------------------------
8339 if (mask & VARIABLE_LIQUIDTYPE)
8340 {
8341 int liquidtype = Math.Round(floats.Get(index));
8342 SetLiquidType(liquidtype);
8343 index++;
8344 }
8345 //--------------------------------------------
8346 if (mask & VARIABLE_COLOR)
8347 {
8348 m_ColorComponentR = Math.Round(floats.Get(index));
8349 index++;
8350 m_ColorComponentG = Math.Round(floats.Get(index));
8351 index++;
8352 m_ColorComponentB = Math.Round(floats.Get(index));
8353 index++;
8354 m_ColorComponentA = Math.Round(floats.Get(index));
8355 index++;
8356 }
8357 //--------------------------------------------
8358 if (mask & VARIABLE_CLEANNESS)
8359 {
8360 int cleanness = Math.Round(floats.Get(index));
8361 SetCleanness(cleanness);
8362 index++;
8363 }
8364 }
8365
8366 override void WriteVarsToCTX(ParamsWriteContext ctx)
8367 {
8368 super.WriteVarsToCTX(ctx);
8369
8370 //--------------------------------------------
8371 if (IsVariableSet(VARIABLE_QUANTITY))
8372 {
8373 ctx.Write(GetQuantity());
8374 }
8375 //--------------------------------------------
8376 if (IsVariableSet(VARIABLE_WET))
8377 {
8378 ctx.Write(GetWet());
8379 }
8380 //--------------------------------------------
8381 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8382 {
8383 ctx.Write(GetLiquidType());
8384 }
8385 //--------------------------------------------
8386 if (IsVariableSet(VARIABLE_COLOR))
8387 {
8388 int r,g,b,a;
8389 GetColor(r,g,b,a);
8390 ctx.Write(r);
8391 ctx.Write(g);
8392 ctx.Write(b);
8393 ctx.Write(a);
8394 }
8395 //--------------------------------------------
8396 if (IsVariableSet(VARIABLE_CLEANNESS))
8397 {
8398 ctx.Write(GetCleanness());
8399 }
8400 }
8401
8402 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
8403 {
8404 if (!super.ReadVarsFromCTX(ctx,version))
8405 return false;
8406
8407 int intValue;
8408 float value;
8409
8410 if (version < 140)
8411 {
8412 if (!ctx.Read(intValue))
8413 return false;
8414
8415 m_VariablesMask = intValue;
8416 }
8417
8418 if (m_VariablesMask & VARIABLE_QUANTITY)
8419 {
8420 if (!ctx.Read(value))
8421 return false;
8422
8423 if (IsStoreLoad())
8424 {
8426 }
8427 else
8428 {
8429 SetQuantity(value, true, false, false, false);
8430 }
8431 }
8432 //--------------------------------------------
8433 if (version < 140)
8434 {
8435 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8436 {
8437 if (!ctx.Read(value))
8438 return false;
8439 SetTemperatureDirect(value);
8440 }
8441 }
8442 //--------------------------------------------
8443 if (m_VariablesMask & VARIABLE_WET)
8444 {
8445 if (!ctx.Read(value))
8446 return false;
8447 SetWet(value);
8448 }
8449 //--------------------------------------------
8450 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
8451 {
8452 if (!ctx.Read(intValue))
8453 return false;
8454 SetLiquidType(intValue);
8455 }
8456 //--------------------------------------------
8457 if (m_VariablesMask & VARIABLE_COLOR)
8458 {
8459 int r,g,b,a;
8460 if (!ctx.Read(r))
8461 return false;
8462 if (!ctx.Read(g))
8463 return false;
8464 if (!ctx.Read(b))
8465 return false;
8466 if (!ctx.Read(a))
8467 return false;
8468
8469 SetColor(r,g,b,a);
8470 }
8471 //--------------------------------------------
8472 if (m_VariablesMask & VARIABLE_CLEANNESS)
8473 {
8474 if (!ctx.Read(intValue))
8475 return false;
8476 SetCleanness(intValue);
8477 }
8478 //--------------------------------------------
8479 if (version >= 138 && version < 140)
8480 {
8481 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8482 {
8483 if (!ctx.Read(intValue))
8484 return false;
8485 SetFrozen(intValue);
8486 }
8487 }
8488
8489 return true;
8490 }
8491
8492 //----------------------------------------------------------------
8493 override bool OnStoreLoad(ParamsReadContext ctx, int version)
8494 {
8495 m_IsStoreLoad = true;
8497 {
8498 m_FixDamageSystemInit = true;
8499 }
8500
8501 if (!super.OnStoreLoad(ctx, version))
8502 {
8503 m_IsStoreLoad = false;
8504 return false;
8505 }
8506
8507 if (version >= 114)
8508 {
8509 bool hasQuickBarIndexSaved;
8510
8511 if (!ctx.Read(hasQuickBarIndexSaved))
8512 {
8513 m_IsStoreLoad = false;
8514 return false;
8515 }
8516
8517 if (hasQuickBarIndexSaved)
8518 {
8519 int itmQBIndex;
8520
8521 //Load quickbar item bind
8522 if (!ctx.Read(itmQBIndex))
8523 {
8524 m_IsStoreLoad = false;
8525 return false;
8526 }
8527
8528 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
8529 if (itmQBIndex != -1 && parentPlayer)
8530 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
8531 }
8532 }
8533 else
8534 {
8535 // Backup of how it used to be
8536 PlayerBase player;
8537 int itemQBIndex;
8538 if (version == int.MAX)
8539 {
8540 if (!ctx.Read(itemQBIndex))
8541 {
8542 m_IsStoreLoad = false;
8543 return false;
8544 }
8545 }
8546 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
8547 {
8548 //Load quickbar item bind
8549 if (!ctx.Read(itemQBIndex))
8550 {
8551 m_IsStoreLoad = false;
8552 return false;
8553 }
8554 if (itemQBIndex != -1 && player)
8555 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
8556 }
8557 }
8558
8559 if (version < 140)
8560 {
8561 // variable management system
8562 if (!LoadVariables(ctx, version))
8563 {
8564 m_IsStoreLoad = false;
8565 return false;
8566 }
8567 }
8568
8569 //agent trasmission system
8570 if (!LoadAgents(ctx, version))
8571 {
8572 m_IsStoreLoad = false;
8573 return false;
8574 }
8575 if (version >= 132)
8576 {
8577 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8578 if (raib)
8579 {
8580 if (!raib.OnStoreLoad(ctx,version))
8581 {
8582 m_IsStoreLoad = false;
8583 return false;
8584 }
8585 }
8586 }
8587
8588 m_IsStoreLoad = false;
8589 return true;
8590 }
8591
8592 //----------------------------------------------------------------
8593
8594 override void OnStoreSave(ParamsWriteContext ctx)
8595 {
8596 super.OnStoreSave(ctx);
8597
8598 PlayerBase player;
8599 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
8600 {
8601 ctx.Write(true); // Keep track of if we should actually read this in or not
8602 //Save quickbar item bind
8603 int itemQBIndex = -1;
8604 itemQBIndex = player.FindQuickBarEntityIndex(this);
8605 ctx.Write(itemQBIndex);
8606 }
8607 else
8608 {
8609 ctx.Write(false); // Keep track of if we should actually read this in or not
8610 }
8611
8612 SaveAgents(ctx);//agent trasmission system
8613
8614 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8615 if (raib)
8616 {
8617 raib.OnStoreSave(ctx);
8618 }
8619 }
8620 //----------------------------------------------------------------
8621
8622 override void AfterStoreLoad()
8623 {
8624 super.AfterStoreLoad();
8625
8627 {
8629 }
8630
8631 if (GetStoreLoadedQuantity() != float.LOWEST)
8632 {
8634 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
8635 }
8636 }
8637
8638 override void EEOnAfterLoad()
8639 {
8640 super.EEOnAfterLoad();
8641
8643 {
8644 m_FixDamageSystemInit = false;
8645 }
8646
8649 }
8650
8651 bool CanBeDisinfected()
8652 {
8653 return false;
8654 }
8655
8656
8657 //----------------------------------------------------------------
8658 override void OnVariablesSynchronized()
8659 {
8660 if (m_Initialized)
8661 {
8662 #ifdef PLATFORM_CONSOLE
8663 //bruteforce it is
8664 if (IsSplitable())
8665 {
8666 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
8667 if (menu)
8668 {
8669 menu.Refresh();
8670 }
8671 }
8672 #endif
8673 }
8674
8676 {
8677 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8678 m_WantPlayImpactSound = false;
8679 }
8680
8682 {
8683 SetWeightDirty();
8685 }
8686 if (m_VarWet != m_VarWetPrev)
8687 {
8690 }
8691
8692 if (m_SoundSyncPlay != 0)
8693 {
8694 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
8695 m_SoundSyncPlay = 0;
8696 }
8697 if (m_SoundSyncStop != 0)
8698 {
8699 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
8700 m_SoundSyncStop = 0;
8701 }
8702
8703 super.OnVariablesSynchronized();
8704 }
8705
8706 //------------------------- Quantity
8707 //----------------------------------------------------------------
8709 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
8710 {
8711 if (!IsServerCheck(allow_client))
8712 return false;
8713
8714 if (!HasQuantity())
8715 return false;
8716
8717 float min = GetQuantityMin();
8718 float max = GetQuantityMax();
8719
8720 if (value <= (min + 0.001))
8721 value = min;
8722
8723 if (value == min)
8724 {
8725 if (destroy_config)
8726 {
8727 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
8728 if (dstr)
8729 {
8730 m_VarQuantity = Math.Clamp(value, min, max);
8731 this.Delete();
8732 return true;
8733 }
8734 }
8735 else if (destroy_forced)
8736 {
8737 m_VarQuantity = Math.Clamp(value, min, max);
8738 this.Delete();
8739 return true;
8740 }
8741 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
8742 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
8743 }
8744
8745 float delta = m_VarQuantity;
8746 m_VarQuantity = Math.Clamp(value, min, max);
8747
8748 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
8749 {
8750 delta = m_VarQuantity - delta;
8751
8752 if (delta)
8753 OnQuantityChanged(delta);
8754 }
8755
8756 SetVariableMask(VARIABLE_QUANTITY);
8757
8758 return false;
8759 }
8760
8761 //----------------------------------------------------------------
8763 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
8764 {
8765 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
8766 }
8767 //----------------------------------------------------------------
8768 void SetQuantityMax()
8769 {
8770 float max = GetQuantityMax();
8771 SetQuantity(max);
8772 }
8773
8774 override void SetQuantityToMinimum()
8775 {
8776 float min = GetQuantityMin();
8777 SetQuantity(min);
8778 }
8779 //----------------------------------------------------------------
8781 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
8782 {
8783 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
8784 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
8785 SetQuantity(result, destroy_config, destroy_forced);
8786 }
8787
8788 //----------------------------------------------------------------
8790 override float GetQuantityNormalized()
8791 {
8792 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
8793 }
8794
8796 {
8797 return GetQuantityNormalized();
8798 }
8799
8800 /*void SetAmmoNormalized(float value)
8801 {
8802 float value_clamped = Math.Clamp(value, 0, 1);
8803 Magazine this_mag = Magazine.Cast(this);
8804 int max_rounds = this_mag.GetAmmoMax();
8805 int result = value * max_rounds;//can the rounded if higher precision is required
8806 this_mag.SetAmmoCount(result);
8807 }*/
8808 //----------------------------------------------------------------
8809 override int GetQuantityMax()
8810 {
8811 int slot = -1;
8812 if (GetInventory())
8813 {
8814 InventoryLocation il = new InventoryLocation;
8815 GetInventory().GetCurrentInventoryLocation(il);
8816 slot = il.GetSlot();
8817 }
8818
8819 return GetTargetQuantityMax(slot);
8820 }
8821
8822 override int GetTargetQuantityMax(int attSlotID = -1)
8823 {
8824 float quantity_max = 0;
8825
8826 if (IsSplitable()) //only stackable/splitable items can check for stack size
8827 {
8828 if (attSlotID != -1)
8829 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
8830
8831 if (quantity_max <= 0)
8832 quantity_max = m_VarStackMax;
8833 }
8834
8835 if (quantity_max <= 0)
8836 quantity_max = m_VarQuantityMax;
8837
8838 return quantity_max;
8839 }
8840 //----------------------------------------------------------------
8841 override int GetQuantityMin()
8842 {
8843 return m_VarQuantityMin;
8844 }
8845 //----------------------------------------------------------------
8846 int GetQuantityInit()
8847 {
8848 return m_VarQuantityInit;
8849 }
8850
8851 //----------------------------------------------------------------
8852 override bool HasQuantity()
8853 {
8854 return !(GetQuantityMax() - GetQuantityMin() == 0);
8855 }
8856
8857 override float GetQuantity()
8858 {
8859 return m_VarQuantity;
8860 }
8861
8862 bool IsFullQuantity()
8863 {
8864 return GetQuantity() >= GetQuantityMax();
8865 }
8866
8867 //Calculates weight of single item without attachments and cargo
8868 override float GetSingleInventoryItemWeightEx()
8869 {
8870 //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
8871 float weightEx = GetWeightEx();//overall weight of the item
8872 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
8873 return weightEx - special;
8874 }
8875
8876 // Obsolete, use GetSingleInventoryItemWeightEx() instead
8878 {
8880 }
8881
8882 override protected float GetWeightSpecialized(bool forceRecalc = false)
8883 {
8884 if (IsSplitable()) //quantity determines size of the stack
8885 {
8886 #ifdef DEVELOPER
8887 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
8888 {
8889 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
8890 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
8891 }
8892 #endif
8893
8894 return GetQuantity() * GetConfigWeightModified();
8895 }
8896 else if (HasEnergyManager())// items with energy manager
8897 {
8898 #ifdef DEVELOPER
8899 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
8900 {
8901 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
8902 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
8903 }
8904 #endif
8905 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
8906 }
8907 else//everything else
8908 {
8909 #ifdef DEVELOPER
8910 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
8911 {
8912 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
8913 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
8914 }
8915 #endif
8916 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
8917 }
8918 }
8919
8921 int GetNumberOfItems()
8922 {
8923 int item_count = 0;
8924 ItemBase item;
8925
8926 if (GetInventory().GetCargo() != NULL)
8927 {
8928 item_count = GetInventory().GetCargo().GetItemCount();
8929 }
8930
8931 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
8932 {
8933 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
8934 if (item)
8935 item_count += item.GetNumberOfItems();
8936 }
8937 return item_count;
8938 }
8939
8941 float GetUnitWeight(bool include_wetness = true)
8942 {
8943 float weight = 0;
8944 float wetness = 1;
8945 if (include_wetness)
8946 wetness += GetWet();
8947 if (IsSplitable()) //quantity determines size of the stack
8948 {
8949 weight = wetness * m_ConfigWeight;
8950 }
8951 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
8952 {
8953 weight = 1;
8954 }
8955 return weight;
8956 }
8957
8958 //-----------------------------------------------------------------
8959
8960 override void ClearInventory()
8961 {
8962 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
8963 {
8964 GameInventory inv = GetInventory();
8965 array<EntityAI> items = new array<EntityAI>;
8966 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
8967 for (int i = 0; i < items.Count(); i++)
8968 {
8969 ItemBase item = ItemBase.Cast(items.Get(i));
8970 if (item)
8971 {
8972 GetGame().ObjectDelete(item);
8973 }
8974 }
8975 }
8976 }
8977
8978 //------------------------- Energy
8979
8980 //----------------------------------------------------------------
8981 float GetEnergy()
8982 {
8983 float energy = 0;
8984 if (HasEnergyManager())
8985 {
8986 energy = GetCompEM().GetEnergy();
8987 }
8988 return energy;
8989 }
8990
8991
8992 override void OnEnergyConsumed()
8993 {
8994 super.OnEnergyConsumed();
8995
8997 }
8998
8999 override void OnEnergyAdded()
9000 {
9001 super.OnEnergyAdded();
9002
9004 }
9005
9006 // Converts energy (from Energy Manager) to quantity, if enabled.
9008 {
9009 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
9010 {
9011 if (HasQuantity())
9012 {
9013 float energy_0to1 = GetCompEM().GetEnergy0To1();
9014 SetQuantityNormalized(energy_0to1);
9015 }
9016 }
9017 }
9018
9019 //----------------------------------------------------------------
9020 float GetHeatIsolationInit()
9021 {
9022 return ConfigGetFloat("heatIsolation");
9023 }
9024
9025 float GetHeatIsolation()
9026 {
9027 return m_HeatIsolation;
9028 }
9029
9030 float GetDryingIncrement(string pIncrementName)
9031 {
9032 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
9033 if (GetGame().ConfigIsExisting(paramPath))
9034 return GetGame().ConfigGetFloat(paramPath);
9035
9036 return 0.0;
9037 }
9038
9039 float GetSoakingIncrement(string pIncrementName)
9040 {
9041 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
9042 if (GetGame().ConfigIsExisting(paramPath))
9043 return GetGame().ConfigGetFloat(paramPath);
9044
9045 return 0.0;
9046 }
9047 //----------------------------------------------------------------
9048 override void SetWet(float value, bool allow_client = false)
9049 {
9050 if (!IsServerCheck(allow_client))
9051 return;
9052
9053 float min = GetWetMin();
9054 float max = GetWetMax();
9055
9056 float previousValue = m_VarWet;
9057
9058 m_VarWet = Math.Clamp(value, min, max);
9059
9060 if (previousValue != m_VarWet)
9061 {
9062 SetVariableMask(VARIABLE_WET);
9063 OnWetChanged(m_VarWet, previousValue);
9064 }
9065 }
9066 //----------------------------------------------------------------
9067 override void AddWet(float value)
9068 {
9069 SetWet(GetWet() + value);
9070 }
9071 //----------------------------------------------------------------
9072 override void SetWetMax()
9073 {
9075 }
9076 //----------------------------------------------------------------
9077 override float GetWet()
9078 {
9079 return m_VarWet;
9080 }
9081 //----------------------------------------------------------------
9082 override float GetWetMax()
9083 {
9084 return m_VarWetMax;
9085 }
9086 //----------------------------------------------------------------
9087 override float GetWetMin()
9088 {
9089 return m_VarWetMin;
9090 }
9091 //----------------------------------------------------------------
9092 override float GetWetInit()
9093 {
9094 return m_VarWetInit;
9095 }
9096 //----------------------------------------------------------------
9097 override void OnWetChanged(float newVal, float oldVal)
9098 {
9099 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
9100 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
9101 if (newLevel != oldLevel)
9102 {
9103 OnWetLevelChanged(newLevel,oldLevel);
9104 }
9105 }
9106
9107 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
9108 {
9109 SetWeightDirty();
9110 }
9111
9112 override EWetnessLevel GetWetLevel()
9113 {
9114 return GetWetLevelInternal(m_VarWet);
9115 }
9116
9117 //----------------------------------------------------------------
9118
9119 override void SetStoreLoad(bool value)
9120 {
9121 m_IsStoreLoad = value;
9122 }
9123
9124 override bool IsStoreLoad()
9125 {
9126 return m_IsStoreLoad;
9127 }
9128
9129 override void SetStoreLoadedQuantity(float value)
9130 {
9131 m_StoreLoadedQuantity = value;
9132 }
9133
9134 override float GetStoreLoadedQuantity()
9135 {
9136 return m_StoreLoadedQuantity;
9137 }
9138
9139 //----------------------------------------------------------------
9140
9141 float GetItemModelLength()
9142 {
9143 if (ConfigIsExisting("itemModelLength"))
9144 {
9145 return ConfigGetFloat("itemModelLength");
9146 }
9147 return 0;
9148 }
9149
9150 float GetItemAttachOffset()
9151 {
9152 if (ConfigIsExisting("itemAttachOffset"))
9153 {
9154 return ConfigGetFloat("itemAttachOffset");
9155 }
9156 return 0;
9157 }
9158
9159 override void SetCleanness(int value, bool allow_client = false)
9160 {
9161 if (!IsServerCheck(allow_client))
9162 return;
9163
9164 int previousValue = m_Cleanness;
9165
9166 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
9167
9168 if (previousValue != m_Cleanness)
9169 SetVariableMask(VARIABLE_CLEANNESS);
9170 }
9171
9172 override int GetCleanness()
9173 {
9174 return m_Cleanness;
9175 }
9176
9178 {
9179 return true;
9180 }
9181
9182 //----------------------------------------------------------------
9183 // ATTACHMENT LOCKING
9184 // Getters relevant to generic ActionLockAttachment
9185 int GetLockType()
9186 {
9187 return m_LockType;
9188 }
9189
9190 string GetLockSoundSet()
9191 {
9192 return m_LockSoundSet;
9193 }
9194
9195 //----------------------------------------------------------------
9196 //------------------------- Color
9197 // sets items color variable given color components
9198 override void SetColor(int r, int g, int b, int a)
9199 {
9204 SetVariableMask(VARIABLE_COLOR);
9205 }
9207 override void GetColor(out int r,out int g,out int b,out int a)
9208 {
9213 }
9214
9215 bool IsColorSet()
9216 {
9217 return IsVariableSet(VARIABLE_COLOR);
9218 }
9219
9221 string GetColorString()
9222 {
9223 int r,g,b,a;
9224 GetColor(r,g,b,a);
9225 r = r/255;
9226 g = g/255;
9227 b = b/255;
9228 a = a/255;
9229 return MiscGameplayFunctions.GetColorString(r, g, b, a);
9230 }
9231 //----------------------------------------------------------------
9232 //------------------------- LiquidType
9233
9234 override void SetLiquidType(int value, bool allow_client = false)
9235 {
9236 if (!IsServerCheck(allow_client))
9237 return;
9238
9239 int old = m_VarLiquidType;
9240 m_VarLiquidType = value;
9241 OnLiquidTypeChanged(old,value);
9242 SetVariableMask(VARIABLE_LIQUIDTYPE);
9243 }
9244
9245 int GetLiquidTypeInit()
9246 {
9247 return ConfigGetInt("varLiquidTypeInit");
9248 }
9249
9250 override int GetLiquidType()
9251 {
9252 return m_VarLiquidType;
9253 }
9254
9255 protected void OnLiquidTypeChanged(int oldType, int newType)
9256 {
9257 if (newType == LIQUID_NONE && GetIsFrozen())
9258 SetFrozen(false);
9259 }
9260
9262 void UpdateQuickbarShortcutVisibility(PlayerBase player)
9263 {
9264 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9265 }
9266
9267 // -------------------------------------------------------------------------
9269 void OnInventoryEnter(Man player)
9270 {
9271 PlayerBase nplayer;
9272 if (PlayerBase.CastTo(nplayer, player))
9273 {
9274 m_CanPlayImpactSound = true;
9275 //nplayer.OnItemInventoryEnter(this);
9276 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9277 }
9278 }
9279
9280 // -------------------------------------------------------------------------
9282 void OnInventoryExit(Man player)
9283 {
9284 PlayerBase nplayer;
9285 if (PlayerBase.CastTo(nplayer,player))
9286 {
9287 //nplayer.OnItemInventoryExit(this);
9288 nplayer.SetEnableQuickBarEntityShortcut(this,false);
9289
9290 }
9291
9292 //if (!GetGame().IsDedicatedServer())
9293 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
9294
9295
9296 if (HasEnergyManager())
9297 {
9298 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
9299 }
9300 }
9301
9302 // ADVANCED PLACEMENT EVENTS
9303 override void OnPlacementStarted(Man player)
9304 {
9305 super.OnPlacementStarted(player);
9306
9307 SetTakeable(false);
9308 }
9309
9310 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
9311 {
9312 if (m_AdminLog)
9313 {
9314 m_AdminLog.OnPlacementComplete(player, this);
9315 }
9316
9317 super.OnPlacementComplete(player, position, orientation);
9318 }
9319
9320 //-----------------------------
9321 // AGENT SYSTEM
9322 //-----------------------------
9323 //--------------------------------------------------------------------------
9324 bool ContainsAgent(int agent_id)
9325 {
9326 if (agent_id & m_AttachedAgents)
9327 {
9328 return true;
9329 }
9330 else
9331 {
9332 return false;
9333 }
9334 }
9335
9336 //--------------------------------------------------------------------------
9337 override void RemoveAgent(int agent_id)
9338 {
9339 if (ContainsAgent(agent_id))
9340 {
9341 m_AttachedAgents = ~agent_id & m_AttachedAgents;
9342 }
9343 }
9344
9345 //--------------------------------------------------------------------------
9346 override void RemoveAllAgents()
9347 {
9348 m_AttachedAgents = 0;
9349 }
9350 //--------------------------------------------------------------------------
9351 override void RemoveAllAgentsExcept(int agent_to_keep)
9352 {
9353 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
9354 }
9355 // -------------------------------------------------------------------------
9356 override void InsertAgent(int agent, float count = 1)
9357 {
9358 if (count < 1)
9359 return;
9360 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
9362 }
9363
9365 void TransferAgents(int agents)
9366 {
9368 }
9369
9370 // -------------------------------------------------------------------------
9371 override int GetAgents()
9372 {
9373 return m_AttachedAgents;
9374 }
9375 //----------------------------------------------------------------------
9376
9377 /*int GetContaminationType()
9378 {
9379 int contamination_type;
9380
9381 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
9382 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
9383 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
9384 const int DIRTY_MASK = eAgents.WOUND_AGENT;
9385
9386 Edible_Base edible = Edible_Base.Cast(this);
9387 int agents = GetAgents();
9388 if (edible)
9389 {
9390 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
9391 if (profile)
9392 {
9393 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
9394 }
9395 }
9396 if (agents & CONTAMINATED_MASK)
9397 {
9398 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
9399 }
9400 if (agents & POISONED_MASK)
9401 {
9402 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
9403 }
9404 if (agents & NERVE_GAS_MASK)
9405 {
9406 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
9407 }
9408 if (agents & DIRTY_MASK)
9409 {
9410 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
9411 }
9412
9413 return agents;
9414 }*/
9415
9416 // -------------------------------------------------------------------------
9417 bool LoadAgents(ParamsReadContext ctx, int version)
9418 {
9419 if (!ctx.Read(m_AttachedAgents))
9420 return false;
9421 return true;
9422 }
9423 // -------------------------------------------------------------------------
9425 {
9426
9428 }
9429 // -------------------------------------------------------------------------
9430
9432 override void CheckForRoofLimited(float timeTresholdMS = 3000)
9433 {
9434 super.CheckForRoofLimited(timeTresholdMS);
9435
9436 float time = GetGame().GetTime();
9437 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
9438 {
9439 m_PreviousRoofTestTime = time;
9440 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
9441 }
9442 }
9443
9444 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
9445 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
9446 {
9447 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
9448 {
9449 return 0;
9450 }
9451
9452 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
9453 {
9454 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
9455 if (filter)
9456 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
9457 else
9458 return 0;//otherwise return 0 when no filter attached
9459 }
9460
9461 string subclassPath, entryName;
9462
9463 switch (type)
9464 {
9465 case DEF_BIOLOGICAL:
9466 entryName = "biological";
9467 break;
9468 case DEF_CHEMICAL:
9469 entryName = "chemical";
9470 break;
9471 default:
9472 entryName = "biological";
9473 break;
9474 }
9475
9476 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
9477
9478 return GetGame().ConfigGetFloat(subclassPath + entryName);
9479 }
9480
9481
9482
9484 override void EEOnCECreate()
9485 {
9486 if (!IsMagazine())
9488
9490 }
9491
9492
9493 //-------------------------
9494 // OPEN/CLOSE USER ACTIONS
9495 //-------------------------
9497 void Open();
9498 void Close();
9499 bool IsOpen()
9500 {
9501 return true;
9502 }
9503
9504 override bool CanDisplayCargo()
9505 {
9506 return IsOpen();
9507 }
9508
9509
9510 // ------------------------------------------------------------
9511 // CONDITIONS
9512 // ------------------------------------------------------------
9513 override bool CanPutInCargo(EntityAI parent)
9514 {
9515 if (parent)
9516 {
9517 if (parent.IsInherited(DayZInfected))
9518 return true;
9519
9520 if (!parent.IsRuined())
9521 return true;
9522 }
9523
9524 return true;
9525 }
9526
9527 override bool CanPutAsAttachment(EntityAI parent)
9528 {
9529 if (!super.CanPutAsAttachment(parent))
9530 {
9531 return false;
9532 }
9533
9534 if (!IsRuined() && !parent.IsRuined())
9535 {
9536 return true;
9537 }
9538
9539 return false;
9540 }
9541
9542 override bool CanReceiveItemIntoCargo(EntityAI item)
9543 {
9544 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9545 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9546 // return false;
9547
9548 return super.CanReceiveItemIntoCargo(item);
9549 }
9550
9551 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
9552 {
9553 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9554 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9555 // return false;
9556
9557 GameInventory attachmentInv = attachment.GetInventory();
9558 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9559 {
9560 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9561 return false;
9562 }
9563
9564 InventoryLocation loc = new InventoryLocation();
9565 attachment.GetInventory().GetCurrentInventoryLocation(loc);
9566 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
9567 return false;
9568
9569 return super.CanReceiveAttachment(attachment, slotId);
9570 }
9571
9572 override bool CanReleaseAttachment(EntityAI attachment)
9573 {
9574 if (!super.CanReleaseAttachment(attachment))
9575 return false;
9576
9577 return GetInventory().AreChildrenAccessible();
9578 }
9579
9580 /*override bool CanLoadAttachment(EntityAI attachment)
9581 {
9582 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9583 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9584 // return false;
9585
9586 GameInventory attachmentInv = attachment.GetInventory();
9587 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9588 {
9589 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
9590 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
9591
9592 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9593 return false;
9594 }
9595
9596 return super.CanLoadAttachment(attachment);
9597 }*/
9598
9599 // Plays muzzle flash particle effects
9600 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9601 {
9602 int id = muzzle_owner.GetMuzzleID();
9603 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
9604
9605 if (WPOF_array)
9606 {
9607 for (int i = 0; i < WPOF_array.Count(); i++)
9608 {
9609 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
9610
9611 if (WPOF)
9612 {
9613 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
9614 }
9615 }
9616 }
9617 }
9618
9619 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
9620 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9621 {
9622 int id = muzzle_owner.GetMuzzleID();
9623 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
9624
9625 if (WPOBE_array)
9626 {
9627 for (int i = 0; i < WPOBE_array.Count(); i++)
9628 {
9629 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
9630
9631 if (WPOBE)
9632 {
9633 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9634 }
9635 }
9636 }
9637 }
9638
9639 // Plays all weapon overheating particles
9640 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9641 {
9642 int id = muzzle_owner.GetMuzzleID();
9643 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9644
9645 if (WPOOH_array)
9646 {
9647 for (int i = 0; i < WPOOH_array.Count(); i++)
9648 {
9649 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9650
9651 if (WPOOH)
9652 {
9653 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9654 }
9655 }
9656 }
9657 }
9658
9659 // Updates all weapon overheating particles
9660 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9661 {
9662 int id = muzzle_owner.GetMuzzleID();
9663 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9664
9665 if (WPOOH_array)
9666 {
9667 for (int i = 0; i < WPOOH_array.Count(); i++)
9668 {
9669 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9670
9671 if (WPOOH)
9672 {
9673 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9674 }
9675 }
9676 }
9677 }
9678
9679 // Stops overheating particles
9680 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9681 {
9682 int id = muzzle_owner.GetMuzzleID();
9683 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9684
9685 if (WPOOH_array)
9686 {
9687 for (int i = 0; i < WPOOH_array.Count(); i++)
9688 {
9689 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9690
9691 if (WPOOH)
9692 {
9693 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9694 }
9695 }
9696 }
9697 }
9698
9699 //----------------------------------------------------------------
9700 //Item Behaviour - unified approach
9701 override bool IsHeavyBehaviour()
9702 {
9703 if (m_ItemBehaviour == 0)
9704 {
9705 return true;
9706 }
9707
9708 return false;
9709 }
9710
9711 override bool IsOneHandedBehaviour()
9712 {
9713 if (m_ItemBehaviour == 1)
9714 {
9715 return true;
9716 }
9717
9718 return false;
9719 }
9720
9721 override bool IsTwoHandedBehaviour()
9722 {
9723 if (m_ItemBehaviour == 2)
9724 {
9725 return true;
9726 }
9727
9728 return false;
9729 }
9730
9731 bool IsDeployable()
9732 {
9733 return false;
9734 }
9735
9737 float GetDeployTime()
9738 {
9739 return UATimeSpent.DEFAULT_DEPLOY;
9740 }
9741
9742
9743 //----------------------------------------------------------------
9744 // Item Targeting (User Actions)
9745 override void SetTakeable(bool pState)
9746 {
9747 m_IsTakeable = pState;
9748 SetSynchDirty();
9749 }
9750
9751 override bool IsTakeable()
9752 {
9753 return m_IsTakeable;
9754 }
9755
9756 // For cases where we want to show object widget which cant be taken to hands
9758 {
9759 return false;
9760 }
9761
9763 protected void PreLoadSoundAttachmentType()
9764 {
9765 string att_type = "None";
9766
9767 if (ConfigIsExisting("soundAttType"))
9768 {
9769 att_type = ConfigGetString("soundAttType");
9770 }
9771
9772 m_SoundAttType = att_type;
9773 }
9774
9775 override string GetAttachmentSoundType()
9776 {
9777 return m_SoundAttType;
9778 }
9779
9780 //----------------------------------------------------------------
9781 //SOUNDS - ItemSoundHandler
9782 //----------------------------------------------------------------
9783
9784 string GetPlaceSoundset(); // played when deploy starts
9785 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
9786 string GetDeploySoundset(); // played when deploy sucessfully finishes
9787 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
9788 string GetFoldSoundset(); // played when fold sucessfully finishes
9789
9791 {
9792 if (!m_ItemSoundHandler)
9794
9795 return m_ItemSoundHandler;
9796 }
9797
9798 // override to initialize sounds
9799 protected void InitItemSounds()
9800 {
9801 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
9802 return;
9803
9805
9806 if (GetPlaceSoundset() != string.Empty)
9807 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
9808
9809 if (GetDeploySoundset() != string.Empty)
9810 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
9811
9812 SoundParameters params = new SoundParameters();
9813 params.m_Loop = true;
9814 if (GetLoopDeploySoundset() != string.Empty)
9815 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
9816 }
9817
9818 // Start sound using ItemSoundHandler
9819 void StartItemSoundServer(int id)
9820 {
9821 if (!GetGame().IsServer())
9822 return;
9823
9824 m_SoundSyncPlay = id;
9825 SetSynchDirty();
9826
9827 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
9829 }
9830
9831 // Stop sound using ItemSoundHandler
9832 void StopItemSoundServer(int id)
9833 {
9834 if (!GetGame().IsServer())
9835 return;
9836
9837 m_SoundSyncStop = id;
9838 SetSynchDirty();
9839
9840 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
9842 }
9843
9844 protected void ClearStartItemSoundServer()
9845 {
9846 m_SoundSyncPlay = 0;
9847 }
9848
9849 protected void ClearStopItemSoundServer()
9850 {
9851 m_SoundSyncStop = 0;
9852 }
9853
9855 void PlayAttachSound(string slot_type)
9856 {
9857 if (!GetGame().IsDedicatedServer())
9858 {
9859 if (ConfigIsExisting("attachSoundSet"))
9860 {
9861 string cfg_path = "";
9862 string soundset = "";
9863 string type_name = GetType();
9864
9865 TStringArray cfg_soundset_array = new TStringArray;
9866 TStringArray cfg_slot_array = new TStringArray;
9867 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
9868 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
9869
9870 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
9871 {
9872 for (int i = 0; i < cfg_soundset_array.Count(); i++)
9873 {
9874 if (cfg_slot_array[i] == slot_type)
9875 {
9876 soundset = cfg_soundset_array[i];
9877 break;
9878 }
9879 }
9880 }
9881
9882 if (soundset != "")
9883 {
9884 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
9885 sound.SetAutodestroy(true);
9886 }
9887 }
9888 }
9889 }
9890
9891 void PlayDetachSound(string slot_type)
9892 {
9893 //TODO - evaluate if needed and devise universal config structure if so
9894 }
9895
9896 void OnApply(PlayerBase player);
9897
9899 {
9900 return 1.0;
9901 };
9902 //returns applicable selection
9903 array<string> GetHeadHidingSelection()
9904 {
9906 }
9907
9909 {
9911 }
9912
9913 WrittenNoteData GetWrittenNoteData() {};
9914
9916 {
9917 SetDynamicPhysicsLifeTime(0.01);
9918 m_ItemBeingDroppedPhys = false;
9919 }
9920
9922 {
9923 array<string> zone_names = new array<string>;
9924 GetDamageZones(zone_names);
9925 for (int i = 0; i < zone_names.Count(); i++)
9926 {
9927 SetHealthMax(zone_names.Get(i),"Health");
9928 }
9929 SetHealthMax("","Health");
9930 }
9931
9933 void SetZoneDamageCEInit()
9934 {
9935 float global_health = GetHealth01("","Health");
9936 array<string> zones = new array<string>;
9937 GetDamageZones(zones);
9938 //set damage of all zones to match global health level
9939 for (int i = 0; i < zones.Count(); i++)
9940 {
9941 SetHealth01(zones.Get(i),"Health",global_health);
9942 }
9943 }
9944
9946 bool IsCoverFaceForShave(string slot_name)
9947 {
9948 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
9949 }
9950
9951 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
9952 {
9953 if (!hasRootAsPlayer)
9954 {
9955 if (refParentIB)
9956 {
9957 // parent is wet
9958 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
9959 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
9960 // parent has liquid inside
9961 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
9962 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
9963 // drying
9964 else if (m_VarWet > m_VarWetMin)
9965 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
9966 }
9967 else
9968 {
9969 // drying on ground or inside non-itembase (car, ...)
9970 if (m_VarWet > m_VarWetMin)
9971 AddWet(-1 * delta * GetDryingIncrement("ground"));
9972 }
9973 }
9974 }
9975
9976 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
9977 {
9979 {
9980 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
9981 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
9982 {
9983 float heatPermCoef = 1.0;
9984 EntityAI ent = this;
9985 while (ent)
9986 {
9987 heatPermCoef *= ent.GetHeatPermeabilityCoef();
9988 ent = ent.GetHierarchyParent();
9989 }
9990
9991 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
9992 }
9993 }
9994 }
9995
9996 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
9997 {
9998 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
9999 EntityAI parent = GetHierarchyParent();
10000 if (!parent)
10001 {
10002 hasParent = false;
10003 hasRootAsPlayer = false;
10004 }
10005 else
10006 {
10007 hasParent = true;
10008 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
10009 refParentIB = ItemBase.Cast(parent);
10010 }
10011 }
10012
10013 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
10014 {
10015 // this is stub, implemented on Edible_Base
10016 }
10017
10018 bool CanDecay()
10019 {
10020 // return true used on selected food clases so they can decay
10021 return false;
10022 }
10023
10024 protected bool CanProcessDecay()
10025 {
10026 // this is stub, implemented on Edible_Base class
10027 // used to determine whether it is still necessary for the food to decay
10028 return false;
10029 }
10030
10031 protected bool CanHaveWetness()
10032 {
10033 // return true used on selected items that have a wetness effect
10034 return false;
10035 }
10036
10038 bool CanBeConsumed(ConsumeConditionData data = null)
10039 {
10040 return !GetIsFrozen() && IsOpen();
10041 }
10042
10043 override void ProcessVariables()
10044 {
10045 bool hasParent = false, hasRootAsPlayer = false;
10046 ItemBase refParentIB;
10047
10048 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
10049 bool foodDecay = g_Game.IsFoodDecayEnabled();
10050
10051 if (wwtu || foodDecay)
10052 {
10053 bool processWetness = wwtu && CanHaveWetness();
10054 bool processTemperature = wwtu && CanHaveTemperature();
10055 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
10056
10057 if (processWetness || processTemperature || processDecay)
10058 {
10059 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
10060
10061 if (processWetness)
10062 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10063
10064 if (processTemperature)
10065 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10066
10067 if (processDecay)
10068 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
10069 }
10070 }
10071 }
10072
10075 {
10076 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
10077 }
10078
10079 override float GetTemperatureFreezeThreshold()
10080 {
10082 return Liquid.GetFreezeThreshold(GetLiquidType());
10083
10084 return super.GetTemperatureFreezeThreshold();
10085 }
10086
10087 override float GetTemperatureThawThreshold()
10088 {
10090 return Liquid.GetThawThreshold(GetLiquidType());
10091
10092 return super.GetTemperatureThawThreshold();
10093 }
10094
10095 override float GetItemOverheatThreshold()
10096 {
10098 return Liquid.GetBoilThreshold(GetLiquidType());
10099
10100 return super.GetItemOverheatThreshold();
10101 }
10102
10103 override float GetTemperatureFreezeTime()
10104 {
10105 if (HasQuantity())
10106 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
10107
10108 return super.GetTemperatureFreezeTime();
10109 }
10110
10111 override float GetTemperatureThawTime()
10112 {
10113 if (HasQuantity())
10114 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
10115
10116 return super.GetTemperatureThawTime();
10117 }
10118
10120 void AffectLiquidContainerOnFill(int liquid_type, float amount);
10122 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
10123
10124 bool IsCargoException4x3(EntityAI item)
10125 {
10126 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
10127 }
10128
10130 {
10131 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
10132 }
10133
10135 void AddLightSourceItem(ItemBase lightsource)
10136 {
10137 m_LightSourceItem = lightsource;
10138 }
10139
10141 {
10142 m_LightSourceItem = null;
10143 }
10144
10146 {
10147 return m_LightSourceItem;
10148 }
10149
10151 array<int> GetValidFinishers()
10152 {
10153 return null;
10154 }
10155
10157 bool GetActionWidgetOverride(out typename name)
10158 {
10159 return false;
10160 }
10161
10162 bool PairWithDevice(notnull ItemBase otherDevice)
10163 {
10164 if (GetGame().IsServer())
10165 {
10166 ItemBase explosive = otherDevice;
10168 if (!trg)
10169 {
10170 trg = RemoteDetonatorTrigger.Cast(otherDevice);
10171 explosive = this;
10172 }
10173
10174 explosive.PairRemote(trg);
10175 trg.SetControlledDevice(explosive);
10176
10177 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
10178 trg.SetPersistentPairID(persistentID);
10179 explosive.SetPersistentPairID(persistentID);
10180
10181 return true;
10182 }
10183 return false;
10184 }
10185
10187 float GetBaitEffectivity()
10188 {
10189 float ret = 1.0;
10190 if (HasQuantity())
10191 ret *= GetQuantityNormalized();
10192 ret *= GetHealth01();
10193
10194 return ret;
10195 }
10196
10197 #ifdef DEVELOPER
10198 override void SetDebugItem()
10199 {
10200 super.SetDebugItem();
10201 _itemBase = this;
10202 }
10203
10204 override string GetDebugText()
10205 {
10206 string text = super.GetDebugText();
10207
10208 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
10209 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
10210
10211 return text;
10212 }
10213 #endif
10214
10215 bool CanBeUsedForSuicide()
10216 {
10217 return true;
10218 }
10219
10221 //DEPRECATED BELOW
10223 // Backwards compatibility
10224 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10225 {
10226 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
10227 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
10228 }
10229
10230 // replaced by ItemSoundHandler
10231 protected EffectSound m_SoundDeployFinish;
10232 protected EffectSound m_SoundPlace;
10233 protected EffectSound m_DeployLoopSoundEx;
10234 protected EffectSound m_SoundDeploy;
10235 bool m_IsPlaceSound;
10236 bool m_IsDeploySound;
10238
10239 string GetDeployFinishSoundset();
10240 void PlayDeploySound();
10241 void PlayDeployFinishSound();
10242 void PlayPlaceSound();
10243 void PlayDeployLoopSoundEx();
10244 void StopDeployLoopSoundEx();
10245 void SoundSynchRemoteReset();
10246 void SoundSynchRemote();
10247 bool UsesGlobalDeploy(){return false;}
10248 bool CanPlayDeployLoopSound(){return false;}
10250 bool IsPlaceSound(){return m_IsPlaceSound;}
10251 bool IsDeploySound(){return m_IsDeploySound;}
10252 void SetIsPlaceSound(bool is_place_sound);
10253 void SetIsDeploySound(bool is_deploy_sound);
10254}
10255
10256EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
10257{
10258 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
10259 if (entity)
10260 {
10261 bool is_item = entity.IsInherited(ItemBase);
10262 if (is_item && full_quantity)
10263 {
10264 ItemBase item = ItemBase.Cast(entity);
10265 item.SetQuantity(item.GetQuantityInit());
10266 }
10267 }
10268 else
10269 {
10270 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
10271 return NULL;
10272 }
10273 return entity;
10274}
10275
10276void SetupSpawnedItem(ItemBase item, float health, float quantity)
10277{
10278 if (item)
10279 {
10280 if (health > 0)
10281 item.SetHealth("", "", health);
10282
10283 if (item.CanHaveTemperature())
10284 {
10285 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
10286 if (item.CanFreeze())
10287 item.SetFrozen(false);
10288 }
10289
10290 if (item.HasEnergyManager())
10291 {
10292 if (quantity >= 0)
10293 {
10294 item.GetCompEM().SetEnergy0To1(quantity);
10295 }
10296 else
10297 {
10298 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
10299 }
10300 }
10301 else if (item.IsMagazine())
10302 {
10303 Magazine mag = Magazine.Cast(item);
10304 if (quantity >= 0)
10305 {
10306 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
10307 }
10308 else
10309 {
10310 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
10311 }
10312
10313 }
10314 else
10315 {
10316 if (quantity >= 0)
10317 {
10318 item.SetQuantityNormalized(quantity, false);
10319 }
10320 else
10321 {
10322 item.SetQuantity(Math.AbsFloat(quantity));
10323 }
10324
10325 }
10326 }
10327}
10328
10329#ifdef DEVELOPER
10330ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
10331#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()