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

◆ SetDebugActionsMask()

static void SpawnItemOnLocation::SetDebugActionsMask ( int mask)
staticprivate

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

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