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

◆ IsLightSource()

bool SpawnItemOnLocation::IsLightSource ( )
private

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

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