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

◆ AddDebugActionsMask()

static void SpawnItemOnLocation::AddDebugActionsMask ( int mask)
staticprivate

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

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

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