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

◆ LoadParticleConfigOnFire()

void SpawnItemOnLocation::LoadParticleConfigOnFire ( int id)
private

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

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

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