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

◆ HasMuzzle()

bool SpawnItemOnLocation::HasMuzzle ( )
private

Returns true if this item has a muzzle (weapons, suppressors)

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

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

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