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

◆ GetMuzzleID()

int SpawnItemOnLocation::GetMuzzleID ( )
private

Returns global muzzle ID. If not found, then it gets automatically registered.

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

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