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

◆ IsNVG()

bool SpawnItemOnLocation::IsNVG ( )
private

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

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