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

◆ IsOverheatingEffectActive()

bool SpawnItemOnLocation::IsOverheatingEffectActive ( )
private

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

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

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