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

◆ RemoveDebugActionsMask()

static void SpawnItemOnLocation::RemoveDebugActionsMask ( int mask)
staticprivate

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

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

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