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

◆ LoadParticleConfigOnFire()

void SpawnItemOnLocation::LoadParticleConfigOnFire ( int id)
private

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

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

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