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

◆ StopOverheating()

void SpawnItemOnLocation::StopOverheating ( ItemBase weapon = null,
string ammoType = "",
ItemBase muzzle_owner = null,
ItemBase suppressor = null,
string config_to_search = "" )
private

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

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

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