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

◆ HasDebugActionsMask()

static bool SpawnItemOnLocation::HasDebugActionsMask ( int mask)
staticprivate

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

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