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

◆ UpdateOverheating()

void SpawnItemOnLocation::UpdateOverheating ( ItemBase weapon = null,
string ammoType = "",
ItemBase muzzle_owner = null,
ItemBase suppressor = null,
string config_to_search = "" )
private

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

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

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