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

◆ SetDebugActionsMask()

static void SpawnItemOnLocation::SetDebugActionsMask ( int mask)
staticprivate

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

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