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

◆ OverrideActionAnimation()

void SpawnItemOnLocation::OverrideActionAnimation ( typename action ,
int commandUID,
int stanceMask = -1,
int commandUIDProne = -1 )
private

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

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

Используется в FarmingHoe::SetActionAnimOverrides() и ItemBase::SetActionAnimOverrides().