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

◆ LoadParticleConfigOnOverheating()

void SpawnItemOnLocation::LoadParticleConfigOnOverheating ( int id)
private

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

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

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