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

◆ AddDebugActionsMask()

static void SpawnItemOnLocation::AddDebugActionsMask ( int mask)
staticprivate

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

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

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