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

◆ OnOverheatingDecay()

void SpawnItemOnLocation::OnOverheatingDecay ( )
private

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

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