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

◆ GetDisinfectQuantity()

float SpawnItemOnLocation::GetDisinfectQuantity ( int system = 0,
Param param1 = null )
private

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

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