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

◆ StopOverheating()

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

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

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