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

◆ IncreaseOverheating()

void SpawnItemOnLocation::IncreaseOverheating ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
private

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

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

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