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

◆ GetOverheatingValue()

float SpawnItemOnLocation::GetOverheatingValue ( )
private

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

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