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

◆ RegisterOverheatingParticle()

void SpawnItemOnLocation::RegisterOverheatingParticle ( Particle p,
float min_heat_coef,
float max_heat_coef,
int particle_id,
Object parent,
vector local_pos,
vector local_ori )
private

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

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