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

◆ IsOverheatingEffectActive()

bool SpawnItemOnLocation::IsOverheatingEffectActive ( )
private

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

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

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