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

◆ GetStoreLoadedQuantity()

override float SpawnItemOnLocation::GetStoreLoadedQuantity ( )
protected

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

8683{
8684 override bool CanPutAsAttachment(EntityAI parent)
8685 {
8686 return true;
8687 }
8688};
8689
8691{
8692
8693};
8694
8695//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8696
8697class ItemBase extends InventoryItem
8698{
8702
8704
8705 static int m_DebugActionsMask;
8707 // ============================================
8708 // Variable Manipulation System
8709 // ============================================
8710 // Quantity
8711
8712 float m_VarQuantity;
8713 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8715 int m_VarQuantityMin;
8716 int m_VarQuantityMax;
8717 int m_Count;
8718 float m_VarStackMax;
8719 float m_StoreLoadedQuantity = float.LOWEST;
8720 // Wet
8721 float m_VarWet;
8722 float m_VarWetPrev;//for client to know wetness changed during synchronization
8723 float m_VarWetInit;
8724 float m_VarWetMin;
8725 float m_VarWetMax;
8726 // Cleanness
8727 int m_Cleanness;
8728 int m_CleannessInit;
8729 int m_CleannessMin;
8730 int m_CleannessMax;
8731 // impact sounds
8733 bool m_CanPlayImpactSound = true;
8734 float m_ImpactSpeed;
8736 //
8737 float m_HeatIsolation;
8738 float m_ItemModelLength;
8739 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8741 int m_VarLiquidType;
8742 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8743 int m_QuickBarBonus;
8744 bool m_IsBeingPlaced;
8745 bool m_IsHologram;
8746 bool m_IsTakeable;
8747 bool m_ThrowItemOnDrop;
8750 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8751 bool can_this_be_combined; //Check if item can be combined
8752 bool m_CanThisBeSplit; //Check if item can be split
8753 bool m_IsStoreLoad = false;
8754 bool m_CanShowQuantity;
8755 bool m_HasQuantityBar;
8756 protected bool m_CanBeDigged;
8757 protected bool m_IsResultOfSplit
8758
8759 string m_SoundAttType;
8760 // items color variables
8765 //-------------------------------------------------------
8766
8767 // light source managing
8769
8773
8774 //==============================================
8775 // agent system
8776 private int m_AttachedAgents;
8777
8779 void TransferModifiers(PlayerBase reciever);
8780
8781
8782 // Weapons & suppressors particle effects
8786 ref static map<string, int> m_WeaponTypeToID;
8787 static int m_LastRegisteredWeaponID = 0;
8788
8789 // Overheating effects
8791 float m_OverheatingShots;
8792 ref Timer m_CheckOverheating;
8793 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8794 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8795 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8796 ref array <ref OverheatingParticle> m_OverheatingParticles;
8797
8799 protected bool m_HideSelectionsBySlot;
8800
8801 // Admin Log
8802 PluginAdminLog m_AdminLog;
8803
8804 // misc
8805 ref Timer m_PhysDropTimer;
8806
8807 // Attachment Locking variables
8808 ref array<int> m_CompatibleLocks;
8809 protected int m_LockType;
8810 protected ref EffectSound m_LockingSound;
8811 protected string m_LockSoundSet;
8812
8813 // ItemSoundHandler variables
8814 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8815 protected int m_SoundSyncPlay; // id for sound to play
8816 protected int m_SoundSyncStop; // id for sound to stop
8817 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
8818
8820
8821 //temperature
8822 private float m_TemperaturePerQuantityWeight;
8823
8824 // -------------------------------------------------------------------------
8825 void ItemBase()
8826 {
8827 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8831
8832 if (!g_Game.IsDedicatedServer())
8833 {
8834 if (HasMuzzle())
8835 {
8837
8839 {
8841 }
8842 }
8843
8845 m_ActionsInitialize = false;
8846 }
8847
8848 m_OldLocation = null;
8849
8850 if (g_Game.IsServer())
8851 {
8852 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8853 }
8854
8855 if (ConfigIsExisting("headSelectionsToHide"))
8856 {
8858 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8859 }
8860
8861 m_HideSelectionsBySlot = false;
8862 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8863 {
8864 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8865 }
8866
8867 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8868
8869 m_IsResultOfSplit = false;
8870
8872 }
8873
8874 override void InitItemVariables()
8875 {
8876 super.InitItemVariables();
8877
8878 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8879 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8880 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8881 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8882 m_VarStackMax = ConfigGetFloat("varStackMax");
8883 m_Count = ConfigGetInt("count");
8884
8885 m_CanShowQuantity = ConfigGetBool("quantityShow");
8886 m_HasQuantityBar = ConfigGetBool("quantityBar");
8887
8888 m_CleannessInit = ConfigGetInt("varCleannessInit");
8890 m_CleannessMin = ConfigGetInt("varCleannessMin");
8891 m_CleannessMax = ConfigGetInt("varCleannessMax");
8892
8893 m_WantPlayImpactSound = false;
8894 m_ImpactSpeed = 0.0;
8895
8896 m_VarWetInit = ConfigGetFloat("varWetInit");
8898 m_VarWetMin = ConfigGetFloat("varWetMin");
8899 m_VarWetMax = ConfigGetFloat("varWetMax");
8900
8901 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8902 if (IsLiquidContainer() && GetQuantity() != 0)
8904 m_IsBeingPlaced = false;
8905 m_IsHologram = false;
8906 m_IsTakeable = true;
8907 m_CanBeMovedOverride = false;
8911 m_CanBeDigged = ConfigGetBool("canBeDigged");
8912
8913 m_CompatibleLocks = new array<int>();
8914 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8915 m_LockType = ConfigGetInt("lockType");
8916
8917 //Define if item can be split and set ability to be combined accordingly
8918 m_CanThisBeSplit = false;
8919 can_this_be_combined = false;
8920 if (ConfigIsExisting("canBeSplit"))
8921 {
8922 can_this_be_combined = ConfigGetBool("canBeSplit");
8924 }
8925
8926 m_ItemBehaviour = -1;
8927 if (ConfigIsExisting("itemBehaviour"))
8928 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8929
8930 //RegisterNetSyncVariableInt("m_VariablesMask");
8931 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8932 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8933 RegisterNetSyncVariableInt("m_VarLiquidType");
8934 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8935
8936 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8937 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8938 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8939
8940 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8941 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8942 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8943 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8944
8945 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8946 RegisterNetSyncVariableBool("m_IsTakeable");
8947 RegisterNetSyncVariableBool("m_IsHologram");
8948
8951 {
8952 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8953 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8954 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
8955 }
8956
8957 m_LockSoundSet = ConfigGetString("lockSoundSet");
8958
8960 if (ConfigIsExisting("temperaturePerQuantityWeight"))
8961 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
8962
8963 m_SoundSyncSlotID = -1;
8964 }
8965
8966 override int GetQuickBarBonus()
8967 {
8968 return m_QuickBarBonus;
8969 }
8970
8971 void InitializeActions()
8972 {
8974 if (!m_InputActionMap)
8975 {
8977 m_InputActionMap = iam;
8978 SetActions();
8980 }
8981 }
8982
8983 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
8984 {
8986 {
8987 m_ActionsInitialize = true;
8989 }
8990
8991 actions = m_InputActionMap.Get(action_input_type);
8992 }
8993
8994 void SetActions()
8995 {
8996 AddAction(ActionTakeItem);
8997 AddAction(ActionTakeItemToHands);
8998 AddAction(ActionWorldCraft);
9000 AddAction(ActionAttachWithSwitch);
9001 }
9002
9003 void SetActionAnimOverrides(); // Override action animation for specific item
9004
9005 void AddAction(typename actionName)
9006 {
9007 ActionBase action = ActionManagerBase.GetAction(actionName);
9008
9009 if (!action)
9010 {
9011 Debug.LogError("Action " + actionName + " dosn't exist!");
9012 return;
9013 }
9014
9015 typename ai = action.GetInputType();
9016 if (!ai)
9017 {
9018 m_ActionsInitialize = false;
9019 return;
9020 }
9021
9022 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9023 if (!action_array)
9024 {
9025 action_array = new array<ActionBase_Basic>;
9026 m_InputActionMap.Insert(ai, action_array);
9027 }
9028 if (LogManager.IsActionLogEnable())
9029 {
9030 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9031 }
9032
9033 if (action_array.Find(action) != -1)
9034 {
9035 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
9036 }
9037 else
9038 {
9039 action_array.Insert(action);
9040 }
9041 }
9042
9043 void RemoveAction(typename actionName)
9044 {
9045 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9046 ActionBase action = player.GetActionManager().GetAction(actionName);
9047 typename ai = action.GetInputType();
9048 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9049
9050 if (action_array)
9051 {
9052 action_array.RemoveItem(action);
9053 }
9054 }
9055
9056 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
9057 // Set -1 for params which should stay in default state
9058 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
9059 {
9060 ActionOverrideData overrideData = new ActionOverrideData();
9061 overrideData.m_CommandUID = commandUID;
9062 overrideData.m_CommandUIDProne = commandUIDProne;
9063 overrideData.m_StanceMask = stanceMask;
9064
9065 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
9066 if (!actionMap) // create new map of action > overidables map
9067 {
9068 actionMap = new TActionAnimOverrideMap();
9069 m_ItemActionOverrides.Insert(action, actionMap);
9070 }
9071
9072 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9073
9074 }
9075
9076 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9077
9078 ScriptedLightBase GetLight();
9079
9080 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9081 void LoadParticleConfigOnFire(int id)
9082 {
9083 if (!m_OnFireEffect)
9085
9088
9089 string config_to_search = "CfgVehicles";
9090 string muzzle_owner_config;
9091
9092 if (!m_OnFireEffect.Contains(id))
9093 {
9094 if (IsInherited(Weapon))
9095 config_to_search = "CfgWeapons";
9096
9097 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9098
9099 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9100
9101 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
9102
9103 if (config_OnFire_subclass_count > 0)
9104 {
9105 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9106
9107 for (int i = 0; i < config_OnFire_subclass_count; i++)
9108 {
9109 string particle_class = "";
9110 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
9111 string config_OnFire_entry = config_OnFire_class + particle_class;
9112 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9113 WPOF_array.Insert(WPOF);
9114 }
9115
9116
9117 m_OnFireEffect.Insert(id, WPOF_array);
9118 }
9119 }
9120
9121 if (!m_OnBulletCasingEjectEffect.Contains(id))
9122 {
9123 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9124 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9125
9126 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9127
9128 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9129
9130 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9131 {
9132 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9133
9134 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9135 {
9136 string particle_class2 = "";
9137 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9138 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9139 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9140 WPOBE_array.Insert(WPOBE);
9141 }
9142
9143
9144 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9145 }
9146 }
9147 }
9148
9149 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9151 {
9154
9155 if (!m_OnOverheatingEffect.Contains(id))
9156 {
9157 string config_to_search = "CfgVehicles";
9158
9159 if (IsInherited(Weapon))
9160 config_to_search = "CfgWeapons";
9161
9162 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9163 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9164
9165 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
9166 {
9167
9168 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9169
9171 {
9172 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9173 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9174 Error(error);
9175 return;
9176 }
9177
9178 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9179 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9180
9181
9182
9183 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
9184 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9185
9186 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9187 {
9188 string particle_class = "";
9189 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9190 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9191 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
9192
9193 if (entry_type == CT_CLASS)
9194 {
9195 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9196 WPOOH_array.Insert(WPOF);
9197 }
9198 }
9199
9200
9201 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9202 }
9203 }
9204 }
9205
9206 float GetOverheatingValue()
9207 {
9208 return m_OverheatingShots;
9209 }
9210
9211 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9212 {
9213 if (m_MaxOverheatingValue > 0)
9214 {
9216
9217 if (!m_CheckOverheating)
9219
9221 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9222
9223 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9224 }
9225 }
9226
9227 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9228 {
9230 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9231
9233 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9234
9236 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9237
9239 {
9241 }
9242 }
9243
9245 {
9247 }
9248
9249 void OnOverheatingDecay()
9250 {
9251 if (m_MaxOverheatingValue > 0)
9252 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9253 else
9255
9256 if (m_OverheatingShots <= 0)
9257 {
9260 }
9261 else
9262 {
9263 if (!m_CheckOverheating)
9265
9267 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9268 }
9269
9270 CheckOverheating(this, "", this);
9271 }
9272
9273 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9274 {
9276 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9277 }
9278
9279 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9280 {
9282 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9284 }
9285
9286 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9287 {
9289 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9290 }
9291
9292 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9293 {
9295 m_OverheatingParticles = new array<ref OverheatingParticle>;
9296
9297 OverheatingParticle OP = new OverheatingParticle();
9298 OP.RegisterParticle(p);
9299 OP.SetOverheatingLimitMin(min_heat_coef);
9300 OP.SetOverheatingLimitMax(max_heat_coef);
9301 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9302
9303 m_OverheatingParticles.Insert(OP);
9304 }
9305
9306 float GetOverheatingCoef()
9307 {
9308 if (m_MaxOverheatingValue > 0)
9310
9311 return -1;
9312 }
9313
9315 {
9317 {
9318 float overheat_coef = GetOverheatingCoef();
9319 int count = m_OverheatingParticles.Count();
9320
9321 for (int i = count; i > 0; --i)
9322 {
9323 int id = i - 1;
9324 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9325 Particle p = OP.GetParticle();
9326
9327 float overheat_min = OP.GetOverheatingLimitMin();
9328 float overheat_max = OP.GetOverheatingLimitMax();
9329
9330 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9331 {
9332 if (p)
9333 {
9334 p.Stop();
9335 OP.RegisterParticle(null);
9336 }
9337 }
9338 }
9339 }
9340 }
9341
9343 {
9345 {
9346 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9347 {
9348 int id = i - 1;
9349 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9350
9351 if (OP)
9352 {
9353 Particle p = OP.GetParticle();
9354
9355 if (p)
9356 {
9357 p.Stop();
9358 }
9359
9360 delete OP;
9361 }
9362 }
9363
9364 m_OverheatingParticles.Clear();
9366 }
9367 }
9368
9370 float GetInfectionChance(int system = 0, Param param = null)
9371 {
9372 return 0.0;
9373 }
9374
9375
9376 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9377 {
9378 return 250;//default value
9379 }
9380
9381 float GetFilterDamageRatio()
9382 {
9383 return 0;
9384 }
9385
9387 bool HasMuzzle()
9388 {
9389 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9390 return true;
9391
9392 return false;
9393 }
9394
9396 int GetMuzzleID()
9397 {
9398 if (!m_WeaponTypeToID)
9399 m_WeaponTypeToID = new map<string, int>;
9400
9401 if (m_WeaponTypeToID.Contains(GetType()))
9402 {
9403 return m_WeaponTypeToID.Get(GetType());
9404 }
9405 else
9406 {
9407 // Register new weapon ID
9409 }
9410
9412 }
9413
9420 {
9421 return -1;
9422 }
9423
9424
9425
9426 // -------------------------------------------------------------------------
9427 void ~ItemBase()
9428 {
9429 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
9430 {
9431 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9432 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9433
9434 if (r_index >= 0)
9435 {
9436 InventoryLocation r_il = new InventoryLocation;
9437 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9438
9439 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9440 int r_type = r_il.GetType();
9441 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9442 {
9443 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9444 }
9445 else if (r_type == InventoryLocationType.ATTACHMENT)
9446 {
9447 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9448 }
9449
9450 }
9451
9452 player.GetHumanInventory().ClearUserReservedLocation(this);
9453 }
9454
9455 if (m_LockingSound)
9456 SEffectManager.DestroyEffect(m_LockingSound);
9457 }
9458
9459
9460
9461 // -------------------------------------------------------------------------
9462 static int GetDebugActionsMask()
9463 {
9464 return ItemBase.m_DebugActionsMask;
9465 }
9466
9467 static bool HasDebugActionsMask(int mask)
9468 {
9469 return ItemBase.m_DebugActionsMask & mask;
9470 }
9471
9472 static void SetDebugActionsMask(int mask)
9473 {
9474 ItemBase.m_DebugActionsMask = mask;
9475 }
9476
9477 static void AddDebugActionsMask(int mask)
9478 {
9479 ItemBase.m_DebugActionsMask |= mask;
9480 }
9481
9482 static void RemoveDebugActionsMask(int mask)
9483 {
9484 ItemBase.m_DebugActionsMask &= ~mask;
9485 }
9486
9487 static void ToggleDebugActionsMask(int mask)
9488 {
9489 if (HasDebugActionsMask(mask))
9490 {
9492 }
9493 else
9494 {
9495 AddDebugActionsMask(mask);
9496 }
9497 }
9498
9499 // -------------------------------------------------------------------------
9500 void SetCEBasedQuantity()
9501 {
9502 if (GetEconomyProfile())
9503 {
9504 float q_max = GetEconomyProfile().GetQuantityMax();
9505 if (q_max > 0)
9506 {
9507 float q_min = GetEconomyProfile().GetQuantityMin();
9508 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9509
9510 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9511 {
9512 ComponentEnergyManager comp = GetCompEM();
9513 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
9514 {
9515 comp.SetEnergy0To1(quantity_randomized);
9516 }
9517 }
9518 else if (HasQuantity())
9519 {
9520 SetQuantityNormalized(quantity_randomized, false);
9521 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9522 }
9523
9524 }
9525 }
9526 }
9527
9529 void LockToParent()
9530 {
9531 EntityAI parent = GetHierarchyParent();
9532
9533 if (parent)
9534 {
9535 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9536 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9537 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9538 }
9539 }
9540
9542 void UnlockFromParent()
9543 {
9544 EntityAI parent = GetHierarchyParent();
9545
9546 if (parent)
9547 {
9548 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9549 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9550 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9551 }
9552 }
9553
9554 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9555 {
9556 /*
9557 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9558 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
9559 */
9560 ItemBase item2 = ItemBase.Cast(entity2);
9561
9562 if (g_Game.IsClient())
9563 {
9564 if (ScriptInputUserData.CanStoreInputUserData())
9565 {
9566 ScriptInputUserData ctx = new ScriptInputUserData;
9568 ctx.Write(-1);
9569 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9570 ctx.Write(i1);
9571 ctx.Write(item2);
9572 ctx.Write(use_stack_max);
9573 ctx.Write(-1);
9574 ctx.Send();
9575
9576 if (IsCombineAll(item2, use_stack_max))
9577 {
9578 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9579 }
9580 }
9581 }
9582 else if (!g_Game.IsMultiplayer())
9583 {
9584 CombineItems(item2, use_stack_max);
9585 }
9586 }
9587
9588 bool IsLiquidPresent()
9589 {
9590 return (GetLiquidType() != 0 && HasQuantity());
9591 }
9592
9593 bool IsLiquidContainer()
9594 {
9595 return m_LiquidContainerMask != 0;
9596 }
9597
9599 {
9600 return m_LiquidContainerMask;
9601 }
9602
9603 bool IsBloodContainer()
9604 {
9605 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9606 return false;
9607 }
9608
9609 bool IsNVG()
9610 {
9611 return false;
9612 }
9613
9616 bool IsExplosive()
9617 {
9618 return false;
9619 }
9620
9622 {
9623 return "";
9624 }
9625
9627
9628 bool IsLightSource()
9629 {
9630 return false;
9631 }
9632
9634 {
9635 return true;
9636 }
9637
9638 //--- ACTION CONDITIONS
9639 //direction
9640 bool IsFacingPlayer(PlayerBase player, string selection)
9641 {
9642 return true;
9643 }
9644
9645 bool IsPlayerInside(PlayerBase player, string selection)
9646 {
9647 return true;
9648 }
9649
9650 override bool CanObstruct()
9651 {
9652 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9653 return !player || !IsPlayerInside(player, "");
9654 }
9655
9656 override bool IsBeingPlaced()
9657 {
9658 return m_IsBeingPlaced;
9659 }
9660
9661 void SetIsBeingPlaced(bool is_being_placed)
9662 {
9663 m_IsBeingPlaced = is_being_placed;
9664 if (!is_being_placed)
9666 SetSynchDirty();
9667 }
9668
9669 //server-side
9670 void OnEndPlacement() {}
9671
9672 override bool IsHologram()
9673 {
9674 return m_IsHologram;
9675 }
9676
9677 bool CanBeDigged()
9678 {
9679 return m_CanBeDigged;
9680 }
9681
9683 {
9684 return 1;
9685 }
9686
9687 bool CanMakeGardenplot()
9688 {
9689 return false;
9690 }
9691
9692 void SetIsHologram(bool is_hologram)
9693 {
9694 m_IsHologram = is_hologram;
9695 SetSynchDirty();
9696 }
9697 /*
9698 protected float GetNutritionalEnergy()
9699 {
9700 Edible_Base edible = Edible_Base.Cast(this);
9701 return edible.GetFoodEnergy();
9702 }
9703
9704 protected float GetNutritionalWaterContent()
9705 {
9706 Edible_Base edible = Edible_Base.Cast(this);
9707 return edible.GetFoodWater();
9708 }
9709
9710 protected float GetNutritionalIndex()
9711 {
9712 Edible_Base edible = Edible_Base.Cast(this);
9713 return edible.GetFoodNutritionalIndex();
9714 }
9715
9716 protected float GetNutritionalFullnessIndex()
9717 {
9718 Edible_Base edible = Edible_Base.Cast(this);
9719 return edible.GetFoodTotalVolume();
9720 }
9721
9722 protected float GetNutritionalToxicity()
9723 {
9724 Edible_Base edible = Edible_Base.Cast(this);
9725 return edible.GetFoodToxicity();
9726
9727 }
9728 */
9729
9730
9731 // -------------------------------------------------------------------------
9732 override void OnMovedInsideCargo(EntityAI container)
9733 {
9734 super.OnMovedInsideCargo(container);
9735
9736 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9737 }
9738
9739 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9740 {
9741 super.EEItemLocationChanged(oldLoc, newLoc);
9742
9743 PlayerBase newPlayer = null;
9744 PlayerBase oldPlayer = null;
9745
9746 if (newLoc.GetParent())
9747 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9748
9749 if (oldLoc.GetParent())
9750 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9751
9752 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
9753 {
9754 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
9755
9756 if (rIndex >= 0)
9757 {
9758 InventoryLocation rIl = new InventoryLocation;
9759 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
9760
9761 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
9762 int rType = rIl.GetType();
9763 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
9764 {
9765 rIl.GetParent().GetOnReleaseLock().Invoke(this);
9766 }
9767 else if (rType == InventoryLocationType.ATTACHMENT)
9768 {
9769 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
9770 }
9771
9772 }
9773 }
9774
9775 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
9776 {
9777 if (newPlayer)
9778 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
9779
9780 if (newPlayer == oldPlayer)
9781 {
9782 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9783 {
9784 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9785 {
9786 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9787 {
9788 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9789 }
9790 }
9791 else
9792 {
9793 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9794 }
9795 }
9796
9797 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9798 {
9799 int type = oldLoc.GetType();
9800 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9801 {
9802 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9803 }
9804 else if (type == InventoryLocationType.ATTACHMENT)
9805 {
9806 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9807 }
9808 }
9809 if (!m_OldLocation)
9810 {
9811 m_OldLocation = new InventoryLocation;
9812 }
9813 m_OldLocation.Copy(oldLoc);
9814 }
9815 else
9816 {
9817 if (m_OldLocation)
9818 {
9819 m_OldLocation.Reset();
9820 }
9821 }
9822
9823 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
9824 }
9825 else
9826 {
9827 if (newPlayer)
9828 {
9829 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9830 if (resIndex >= 0)
9831 {
9832 InventoryLocation il = new InventoryLocation;
9833 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
9834 ItemBase it = ItemBase.Cast(il.GetItem());
9835 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
9836 int rel_type = il.GetType();
9837 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9838 {
9839 il.GetParent().GetOnReleaseLock().Invoke(it);
9840 }
9841 else if (rel_type == InventoryLocationType.ATTACHMENT)
9842 {
9843 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9844 }
9845 //it.GetOnReleaseLock().Invoke(it);
9846 }
9847 }
9848 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9849 {
9850 //ThrowPhysically(oldPlayer, vector.Zero);
9851 m_ThrowItemOnDrop = false;
9852 }
9853
9854 if (m_OldLocation)
9855 {
9856 m_OldLocation.Reset();
9857 }
9858 }
9859
9860 if (oldLoc.GetType() == InventoryLocationType.TEMP)
9861 {
9862 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
9863 }
9864
9865 if (newLoc.GetType() == InventoryLocationType.TEMP)
9866 {
9867 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
9868 }
9869 }
9870
9871 override void EOnContact(IEntity other, Contact extra)
9872 {
9874 {
9875 int liquidType = -1;
9876 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9877 if (impactSpeed > 0.0)
9878 {
9879 m_ImpactSpeed = impactSpeed;
9880 #ifndef SERVER
9881 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9882 #else
9883 m_WantPlayImpactSound = true;
9884 SetSynchDirty();
9885 #endif
9886 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9887 }
9888 }
9889
9890 #ifdef SERVER
9891 if (GetCompEM() && GetCompEM().IsPlugged())
9892 {
9893 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9894 GetCompEM().UnplugThis();
9895 }
9896 #endif
9897 }
9898
9899 void RefreshPhysics();
9900
9901 override void OnCreatePhysics()
9902 {
9904 }
9905
9906 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9907 {
9908
9909 }
9910 // -------------------------------------------------------------------------
9911 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9912 {
9913 super.OnItemLocationChanged(old_owner, new_owner);
9914
9915 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9916 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9917
9918 if (!relatedPlayer && playerNew)
9919 relatedPlayer = playerNew;
9920
9921 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9922 {
9923 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9924 if (actionMgr)
9925 {
9926 ActionBase currentAction = actionMgr.GetRunningAction();
9927 if (currentAction)
9928 currentAction.OnItemLocationChanged(this);
9929 }
9930 }
9931
9932 Man ownerPlayerOld = null;
9933 Man ownerPlayerNew = null;
9934
9935 if (old_owner)
9936 {
9937 if (old_owner.IsMan())
9938 {
9939 ownerPlayerOld = Man.Cast(old_owner);
9940 }
9941 else
9942 {
9943 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9944 }
9945 }
9946 else
9947 {
9948 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9949 {
9950 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9951
9952 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9953 {
9954 GetCompEM().UnplugThis();
9955 }
9956 }
9957 }
9958
9959 if (new_owner)
9960 {
9961 if (new_owner.IsMan())
9962 {
9963 ownerPlayerNew = Man.Cast(new_owner);
9964 }
9965 else
9966 {
9967 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
9968 }
9969 }
9970
9971 if (ownerPlayerOld != ownerPlayerNew)
9972 {
9973 if (ownerPlayerOld)
9974 {
9975 array<EntityAI> subItemsExit = new array<EntityAI>;
9976 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
9977 for (int i = 0; i < subItemsExit.Count(); i++)
9978 {
9979 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
9980 itemExit.OnInventoryExit(ownerPlayerOld);
9981 }
9982 }
9983
9984 if (ownerPlayerNew)
9985 {
9986 array<EntityAI> subItemsEnter = new array<EntityAI>;
9987 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
9988 for (int j = 0; j < subItemsEnter.Count(); j++)
9989 {
9990 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
9991 itemEnter.OnInventoryEnter(ownerPlayerNew);
9992 }
9993 }
9994 }
9995 else if (ownerPlayerNew != null)
9996 {
9997 PlayerBase nplayer;
9998 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
9999 {
10000 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10001 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10002 for (int k = 0; k < subItemsUpdate.Count(); k++)
10003 {
10004 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10005 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10006 }
10007 }
10008 }
10009
10010 if (old_owner)
10011 old_owner.OnChildItemRemoved(this);
10012 if (new_owner)
10013 new_owner.OnChildItemReceived(this);
10014 }
10015
10016 // -------------------------------------------------------------------------------
10017 override void EEDelete(EntityAI parent)
10018 {
10019 super.EEDelete(parent);
10020 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10021 if (player)
10022 {
10023 OnInventoryExit(player);
10024
10025 if (player.IsAlive())
10026 {
10027 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10028 if (r_index >= 0)
10029 {
10030 InventoryLocation r_il = new InventoryLocation;
10031 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10032
10033 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10034 int r_type = r_il.GetType();
10035 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10036 {
10037 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10038 }
10039 else if (r_type == InventoryLocationType.ATTACHMENT)
10040 {
10041 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10042 }
10043
10044 }
10045
10046 player.RemoveQuickBarEntityShortcut(this);
10047 }
10048 }
10049 }
10050 // -------------------------------------------------------------------------------
10051 override void EEKilled(Object killer)
10052 {
10053 super.EEKilled(killer);
10054
10056 if (killer && killer.IsFireplace() && CanExplodeInFire())
10057 {
10058 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
10059 {
10060 if (IsMagazine())
10061 {
10062 if (Magazine.Cast(this).GetAmmoCount() > 0)
10063 {
10064 ExplodeAmmo();
10065 }
10066 }
10067 else
10068 {
10069 Explode(DamageType.EXPLOSION);
10070 }
10071 }
10072 }
10073 }
10074
10075 override void OnWasAttached(EntityAI parent, int slot_id)
10076 {
10077 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10078
10079 super.OnWasAttached(parent, slot_id);
10080
10081 if (HasQuantity())
10082 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10083
10084 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10085 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
10086 }
10087
10088 override void OnWasDetached(EntityAI parent, int slot_id)
10089 {
10090 super.OnWasDetached(parent, slot_id);
10091
10092 if (HasQuantity())
10093 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10094
10095 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10096 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
10097 }
10098
10099 override string ChangeIntoOnAttach(string slot)
10100 {
10101 int idx;
10102 TStringArray inventory_slots = new TStringArray;
10103 TStringArray attach_types = new TStringArray;
10104
10105 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10106 if (inventory_slots.Count() < 1) //is string
10107 {
10108 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10109 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10110 }
10111 else //is array
10112 {
10113 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10114 }
10115
10116 idx = inventory_slots.Find(slot);
10117 if (idx < 0)
10118 return "";
10119
10120 return attach_types.Get(idx);
10121 }
10122
10123 override string ChangeIntoOnDetach()
10124 {
10125 int idx = -1;
10126 string slot;
10127
10128 TStringArray inventory_slots = new TStringArray;
10129 TStringArray detach_types = new TStringArray;
10130
10131 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10132 if (inventory_slots.Count() < 1) //is string
10133 {
10134 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10135 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10136 }
10137 else //is array
10138 {
10139 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10140 if (detach_types.Count() < 1)
10141 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10142 }
10143
10144 for (int i = 0; i < inventory_slots.Count(); i++)
10145 {
10146 slot = inventory_slots.Get(i);
10147 }
10148
10149 if (slot != "")
10150 {
10151 if (detach_types.Count() == 1)
10152 idx = 0;
10153 else
10154 idx = inventory_slots.Find(slot);
10155 }
10156 if (idx < 0)
10157 return "";
10158
10159 return detach_types.Get(idx);
10160 }
10161
10162 void ExplodeAmmo()
10163 {
10164 //timer
10165 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10166
10167 //min/max time
10168 float min_time = 1;
10169 float max_time = 3;
10170 float delay = Math.RandomFloat(min_time, max_time);
10171
10172 explode_timer.Run(delay, this, "DoAmmoExplosion");
10173 }
10174
10175 void DoAmmoExplosion()
10176 {
10177 Magazine magazine = Magazine.Cast(this);
10178 int pop_sounds_count = 6;
10179 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10180
10181 //play sound
10182 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10183 string sound_name = pop_sounds[ sound_idx ];
10184 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
10185
10186 //remove ammo count
10187 magazine.ServerAddAmmoCount(-1);
10188
10189 //if condition then repeat -> ExplodeAmmo
10190 float min_temp_to_explode = 100; //min temperature for item to explode
10191
10192 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10193 {
10194 ExplodeAmmo();
10195 }
10196 }
10197
10198 // -------------------------------------------------------------------------------
10199 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10200 {
10201 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10202
10203 const int CHANCE_DAMAGE_CARGO = 4;
10204 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10205 const int CHANCE_DAMAGE_NOTHING = 2;
10206
10207 if (IsClothing() || IsContainer() || IsItemTent())
10208 {
10209 float dmg = damageResult.GetDamage("","Health") * -0.5;
10210 int chances;
10211 int rnd;
10212
10213 if (GetInventory().GetCargo())
10214 {
10215 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10216 rnd = Math.RandomInt(0,chances);
10217
10218 if (rnd < CHANCE_DAMAGE_CARGO)
10219 {
10220 DamageItemInCargo(dmg);
10221 }
10222 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10223 {
10225 }
10226 }
10227 else
10228 {
10229 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10230 rnd = Math.RandomInt(0,chances);
10231
10232 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10233 {
10235 }
10236 }
10237 }
10238 }
10239
10240 bool DamageItemInCargo(float damage)
10241 {
10242 CargoBase cargo = GetInventory().GetCargo();
10243 if (cargo)
10244 {
10245 int item_count = cargo.GetItemCount();
10246 if (item_count > 0)
10247 {
10248 int random_pick = Math.RandomInt(0, item_count);
10249 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
10250 if (!item.IsExplosive())
10251 {
10252 item.AddHealth("","",damage);
10253 return true;
10254 }
10255 }
10256 }
10257 return false;
10258 }
10259
10260 bool DamageItemAttachments(float damage)
10261 {
10262 GameInventory inventory = GetInventory();
10263 int attachment_count = inventory.AttachmentCount();
10264 if (attachment_count > 0)
10265 {
10266 int random_pick = Math.RandomInt(0, attachment_count);
10267 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
10268 if (!attachment.IsExplosive())
10269 {
10270 attachment.AddHealth("","",damage);
10271 return true;
10272 }
10273 }
10274 return false;
10275 }
10276
10277 override bool IsSplitable()
10278 {
10279 return m_CanThisBeSplit;
10280 }
10281 //----------------
10282 override bool CanBeSplit()
10283 {
10284 if (IsSplitable() && (GetQuantity() > 1))
10285 return GetInventory().CanRemoveEntity();
10286
10287 return false;
10288 }
10289
10290 protected bool ShouldSplitQuantity(float quantity)
10291 {
10292 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10293 if (!IsSplitable())
10294 return false;
10295
10296 // nothing to split?
10297 if (GetQuantity() <= 1)
10298 return false;
10299
10300 // check if we should re-use the item instead of creating a new copy?
10301 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10302 int delta = GetQuantity() - quantity;
10303 if (delta == 0)
10304 return false;
10305
10306 // valid to split
10307 return true;
10308 }
10309
10310 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10311 {
10312 if (g_Game.IsClient())
10313 {
10314 if (ScriptInputUserData.CanStoreInputUserData())
10315 {
10316 ScriptInputUserData ctx = new ScriptInputUserData;
10318 ctx.Write(1);
10319 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10320 ctx.Write(i1);
10321 ctx.Write(destination_entity);
10322 ctx.Write(true);
10323 ctx.Write(slot_id);
10324 ctx.Send();
10325 }
10326 }
10327 else if (!g_Game.IsMultiplayer())
10328 {
10329 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
10330 }
10331 }
10332
10333 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10334 {
10335 float split_quantity_new;
10336 ItemBase new_item;
10337 float quantity = GetQuantity();
10338 float stack_max = GetTargetQuantityMax(slot_id);
10339 InventoryLocation loc = new InventoryLocation;
10340
10341 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10342 {
10343 if (stack_max <= GetQuantity())
10344 split_quantity_new = stack_max;
10345 else
10346 split_quantity_new = GetQuantity();
10347
10348 if (ShouldSplitQuantity(split_quantity_new))
10349 {
10350 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10351 if (new_item)
10352 {
10353 new_item.SetResultOfSplit(true);
10354 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10355 AddQuantity(-split_quantity_new, false, true);
10356 new_item.SetQuantity(split_quantity_new, false, true);
10357 }
10358 }
10359 }
10360 else if (destination_entity && slot_id == -1)
10361 {
10362 if (quantity > stack_max)
10363 split_quantity_new = stack_max;
10364 else
10365 split_quantity_new = quantity;
10366
10367 if (ShouldSplitQuantity(split_quantity_new))
10368 {
10369 GameInventory destinationInventory = destination_entity.GetInventory();
10370 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10371 {
10372 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10373 new_item = ItemBase.Cast(o);
10374 }
10375
10376 if (new_item)
10377 {
10378 new_item.SetResultOfSplit(true);
10379 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10380 AddQuantity(-split_quantity_new, false, true);
10381 new_item.SetQuantity(split_quantity_new, false, true);
10382 }
10383 }
10384 }
10385 else
10386 {
10387 if (stack_max != 0)
10388 {
10389 if (stack_max < GetQuantity())
10390 {
10391 split_quantity_new = GetQuantity() - stack_max;
10392 }
10393
10394 if (split_quantity_new == 0)
10395 {
10396 if (!g_Game.IsMultiplayer())
10397 player.PhysicalPredictiveDropItem(this);
10398 else
10399 player.ServerDropEntity(this);
10400 return;
10401 }
10402
10403 if (ShouldSplitQuantity(split_quantity_new))
10404 {
10405 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10406
10407 if (new_item)
10408 {
10409 new_item.SetResultOfSplit(true);
10410 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10411 SetQuantity(split_quantity_new, false, true);
10412 new_item.SetQuantity(stack_max, false, true);
10413 new_item.PlaceOnSurface();
10414 }
10415 }
10416 }
10417 }
10418 }
10419
10420 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10421 {
10422 float split_quantity_new;
10423 ItemBase new_item;
10424 float quantity = GetQuantity();
10425 float stack_max = GetTargetQuantityMax(slot_id);
10426 InventoryLocation loc = new InventoryLocation;
10427
10428 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10429 {
10430 if (stack_max <= GetQuantity())
10431 split_quantity_new = stack_max;
10432 else
10433 split_quantity_new = GetQuantity();
10434
10435 if (ShouldSplitQuantity(split_quantity_new))
10436 {
10437 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10438 if (new_item)
10439 {
10440 new_item.SetResultOfSplit(true);
10441 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10442 AddQuantity(-split_quantity_new, false, true);
10443 new_item.SetQuantity(split_quantity_new, false, true);
10444 }
10445 }
10446 }
10447 else if (destination_entity && slot_id == -1)
10448 {
10449 if (quantity > stack_max)
10450 split_quantity_new = stack_max;
10451 else
10452 split_quantity_new = quantity;
10453
10454 if (ShouldSplitQuantity(split_quantity_new))
10455 {
10456 GameInventory destinationInventory = destination_entity.GetInventory();
10457 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10458 {
10459 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10460 new_item = ItemBase.Cast(o);
10461 }
10462
10463 if (new_item)
10464 {
10465 new_item.SetResultOfSplit(true);
10466 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10467 AddQuantity(-split_quantity_new, false, true);
10468 new_item.SetQuantity(split_quantity_new, false, true);
10469 }
10470 }
10471 }
10472 else
10473 {
10474 if (stack_max != 0)
10475 {
10476 if (stack_max < GetQuantity())
10477 {
10478 split_quantity_new = GetQuantity() - stack_max;
10479 }
10480
10481 if (ShouldSplitQuantity(split_quantity_new))
10482 {
10483 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10484
10485 if (new_item)
10486 {
10487 new_item.SetResultOfSplit(true);
10488 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10489 SetQuantity(split_quantity_new, false, true);
10490 new_item.SetQuantity(stack_max, false, true);
10491 new_item.PlaceOnSurface();
10492 }
10493 }
10494 }
10495 }
10496 }
10497
10498 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10499 {
10500 if (g_Game.IsClient())
10501 {
10502 if (ScriptInputUserData.CanStoreInputUserData())
10503 {
10504 ScriptInputUserData ctx = new ScriptInputUserData;
10506 ctx.Write(4);
10507 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10508 ctx.Write(thiz);
10509 dst.WriteToContext(ctx);
10510 ctx.Send();
10511 }
10512 }
10513 else if (!g_Game.IsMultiplayer())
10514 {
10516 }
10517 }
10518
10519 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10520 {
10521 if (g_Game.IsClient())
10522 {
10523 if (ScriptInputUserData.CanStoreInputUserData())
10524 {
10525 ScriptInputUserData ctx = new ScriptInputUserData;
10527 ctx.Write(2);
10528 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10529 ctx.Write(dummy);
10530 ctx.Write(destination_entity);
10531 ctx.Write(true);
10532 ctx.Write(idx);
10533 ctx.Write(row);
10534 ctx.Write(col);
10535 ctx.Send();
10536 }
10537 }
10538 else if (!g_Game.IsMultiplayer())
10539 {
10540 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10541 }
10542 }
10543
10544 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10545 {
10547 }
10548
10549 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10550 {
10551 float quantity = GetQuantity();
10552 float split_quantity_new;
10553 ItemBase new_item;
10554 if (dst.IsValid())
10555 {
10556 int slot_id = dst.GetSlot();
10557 float stack_max = GetTargetQuantityMax(slot_id);
10558
10559 if (quantity > stack_max)
10560 split_quantity_new = stack_max;
10561 else
10562 split_quantity_new = quantity;
10563
10564 if (ShouldSplitQuantity(split_quantity_new))
10565 {
10566 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10567
10568 if (new_item)
10569 {
10570 new_item.SetResultOfSplit(true);
10571 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10572 AddQuantity(-split_quantity_new, false, true);
10573 new_item.SetQuantity(split_quantity_new, false, true);
10574 }
10575
10576 return new_item;
10577 }
10578 }
10579
10580 return null;
10581 }
10582
10583 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10584 {
10585 float quantity = GetQuantity();
10586 float split_quantity_new;
10587 ItemBase new_item;
10588 if (destination_entity)
10589 {
10590 float stackable = GetTargetQuantityMax();
10591 if (quantity > stackable)
10592 split_quantity_new = stackable;
10593 else
10594 split_quantity_new = quantity;
10595
10596 if (ShouldSplitQuantity(split_quantity_new))
10597 {
10598 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10599 if (new_item)
10600 {
10601 new_item.SetResultOfSplit(true);
10602 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10603 AddQuantity(-split_quantity_new, false, true);
10604 new_item.SetQuantity(split_quantity_new, false, true);
10605 }
10606 }
10607 }
10608 }
10609
10610 void SplitIntoStackMaxHandsClient(PlayerBase player)
10611 {
10612 if (g_Game.IsClient())
10613 {
10614 if (ScriptInputUserData.CanStoreInputUserData())
10615 {
10616 ScriptInputUserData ctx = new ScriptInputUserData;
10618 ctx.Write(3);
10619 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10620 ctx.Write(i1);
10621 ItemBase destination_entity = this;
10622 ctx.Write(destination_entity);
10623 ctx.Write(true);
10624 ctx.Write(0);
10625 ctx.Send();
10626 }
10627 }
10628 else if (!g_Game.IsMultiplayer())
10629 {
10630 SplitIntoStackMaxHands(player);
10631 }
10632 }
10633
10634 void SplitIntoStackMaxHands(PlayerBase player)
10635 {
10636 float quantity = GetQuantity();
10637 float split_quantity_new;
10638 ref ItemBase new_item;
10639 if (player)
10640 {
10641 float stackable = GetTargetQuantityMax();
10642 if (quantity > stackable)
10643 split_quantity_new = stackable;
10644 else
10645 split_quantity_new = quantity;
10646
10647 if (ShouldSplitQuantity(split_quantity_new))
10648 {
10649 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10650 new_item = ItemBase.Cast(in_hands);
10651 if (new_item)
10652 {
10653 new_item.SetResultOfSplit(true);
10654 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10655 AddQuantity(-split_quantity_new, false, true);
10656 new_item.SetQuantity(split_quantity_new, false, true);
10657 }
10658 }
10659 }
10660 }
10661
10662 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10663 {
10664 float quantity = GetQuantity();
10665 float split_quantity_new = Math.Floor(quantity * 0.5);
10666
10667 if (!ShouldSplitQuantity(split_quantity_new))
10668 return;
10669
10670 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10671
10672 if (new_item)
10673 {
10674 if (new_item.GetQuantityMax() < split_quantity_new)
10675 {
10676 split_quantity_new = new_item.GetQuantityMax();
10677 }
10678
10679 new_item.SetResultOfSplit(true);
10680 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10681
10682 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10683 {
10684 AddQuantity(-1, false, true);
10685 new_item.SetQuantity(1, false, true);
10686 }
10687 else
10688 {
10689 AddQuantity(-split_quantity_new, false, true);
10690 new_item.SetQuantity(split_quantity_new, false, true);
10691 }
10692 }
10693 }
10694
10695 void SplitItem(PlayerBase player)
10696 {
10697 float quantity = GetQuantity();
10698 float split_quantity_new = Math.Floor(quantity / 2);
10699
10700 if (!ShouldSplitQuantity(split_quantity_new))
10701 return;
10702
10703 InventoryLocation invloc = new InventoryLocation;
10704 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10705
10706 ItemBase new_item;
10707 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10708
10709 if (new_item)
10710 {
10711 if (new_item.GetQuantityMax() < split_quantity_new)
10712 {
10713 split_quantity_new = new_item.GetQuantityMax();
10714 }
10715 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10716 {
10717 AddQuantity(-1, false, true);
10718 new_item.SetQuantity(1, false, true);
10719 }
10720 else if (split_quantity_new > 1)
10721 {
10722 AddQuantity(-split_quantity_new, false, true);
10723 new_item.SetQuantity(split_quantity_new, false, true);
10724 }
10725 }
10726 }
10727
10729 void OnQuantityChanged(float delta)
10730 {
10731 SetWeightDirty();
10732 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10733
10734 if (parent)
10735 parent.OnAttachmentQuantityChangedEx(this, delta);
10736
10737 if (IsLiquidContainer())
10738 {
10739 if (GetQuantityNormalized() <= 0.0)
10740 {
10742 }
10743 else if (GetLiquidType() == LIQUID_NONE)
10744 {
10745 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10747 }
10748 }
10749 }
10750
10753 {
10754 // insert code here
10755 }
10756
10758 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10759 {
10761 }
10762
10763 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10764 {
10765 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10766
10767 if (g_Game.IsServer())
10768 {
10769 if (newLevel == GameConstants.STATE_RUINED)
10770 {
10772 EntityAI parent = GetHierarchyParent();
10773 if (parent && parent.IsFireplace())
10774 {
10775 CargoBase cargo = GetInventory().GetCargo();
10776 if (cargo)
10777 {
10778 for (int i = 0; i < cargo.GetItemCount(); ++i)
10779 {
10780 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10781 }
10782 }
10783 }
10784 }
10785
10786 if (IsResultOfSplit())
10787 {
10788 // reset the splitting result flag, return to normal item behavior
10789 SetResultOfSplit(false);
10790 return;
10791 }
10792
10793 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10794 {
10795 SetCleanness(0);//unclean the item upon damage dealt
10796 }
10797 }
10798 }
10799
10800 // just the split? TODO: verify
10801 override void OnRightClick()
10802 {
10803 super.OnRightClick();
10804
10805 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
10806 {
10807 if (g_Game.IsClient())
10808 {
10809 if (ScriptInputUserData.CanStoreInputUserData())
10810 {
10811 EntityAI root = GetHierarchyRoot();
10812 Man playerOwner = GetHierarchyRootPlayer();
10813 InventoryLocation dst = new InventoryLocation;
10814
10815 // 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
10816 if (!playerOwner && root && root == this)
10817 {
10819 }
10820 else
10821 {
10822 // 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
10823 GetInventory().GetCurrentInventoryLocation(dst);
10824 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10825 {
10826 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10827 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10828 {
10830 }
10831 else
10832 {
10833 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10834 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10835 this shouldnt cause issues within this scope*/
10836 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10837 {
10839 }
10840 else
10841 {
10842 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10843 }
10844 }
10845 }
10846 }
10847
10848 ScriptInputUserData ctx = new ScriptInputUserData;
10850 ctx.Write(4);
10851 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10852 ctx.Write(thiz);
10853 dst.WriteToContext(ctx);
10854 ctx.Write(true); // dummy
10855 ctx.Send();
10856 }
10857 }
10858 else if (!g_Game.IsMultiplayer())
10859 {
10860 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
10861 }
10862 }
10863 }
10864
10865 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10866 {
10867 if (root)
10868 {
10869 vector m4[4];
10870 root.GetTransform(m4);
10871 dst.SetGround(this, m4);
10872 }
10873 else
10874 {
10875 GetInventory().GetCurrentInventoryLocation(dst);
10876 }
10877 }
10878
10879 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10880 {
10881 //TODO: delete check zero quantity check after fix double posts hands fsm events
10882 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10883 return false;
10884
10885 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10886 return false;
10887
10888 //can_this_be_combined = ConfigGetBool("canBeSplit");
10890 return false;
10891
10892
10893 Magazine mag = Magazine.Cast(this);
10894 if (mag)
10895 {
10896 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10897 return false;
10898
10899 if (stack_max_limit)
10900 {
10901 Magazine other_mag = Magazine.Cast(other_item);
10902 if (other_item)
10903 {
10904 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10905 return false;
10906 }
10907
10908 }
10909 }
10910 else
10911 {
10912 //TODO: delete check zero quantity check after fix double posts hands fsm events
10913 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10914 return false;
10915
10916 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10917 return false;
10918 }
10919
10920 PlayerBase player = null;
10921 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10922 {
10923 if (player.GetInventory().HasAttachment(this))
10924 return false;
10925
10926 if (player.IsItemsToDelete())
10927 return false;
10928 }
10929
10930 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10931 return false;
10932
10933 int slotID;
10934 string slotName;
10935 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10936 return false;
10937
10938 return true;
10939 }
10940
10941 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10942 {
10943 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10944 }
10945
10946 bool IsResultOfSplit()
10947 {
10948 return m_IsResultOfSplit;
10949 }
10950
10951 void SetResultOfSplit(bool value)
10952 {
10953 m_IsResultOfSplit = value;
10954 }
10955
10956 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
10957 {
10958 return ComputeQuantityUsedEx(other_item, use_stack_max);
10959 }
10960
10961 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
10962 {
10963 float other_item_quantity = other_item.GetQuantity();
10964 float this_free_space;
10965
10966 float stack_max = GetQuantityMax();
10967
10968 this_free_space = stack_max - GetQuantity();
10969
10970 if (other_item_quantity > this_free_space)
10971 {
10972 return this_free_space;
10973 }
10974 else
10975 {
10976 return other_item_quantity;
10977 }
10978 }
10979
10980 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
10981 {
10982 CombineItems(ItemBase.Cast(entity2),use_stack_max);
10983 }
10984
10985 void CombineItems(ItemBase other_item, bool use_stack_max = true)
10986 {
10987 if (!CanBeCombined(other_item, false))
10988 return;
10989
10990 if (!IsMagazine() && other_item)
10991 {
10992 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
10993 if (quantity_used != 0)
10994 {
10995 float hp1 = GetHealth01("","");
10996 float hp2 = other_item.GetHealth01("","");
10997 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
10998 hpResult = hpResult / (GetQuantity() + quantity_used);
10999
11000 hpResult *= GetMaxHealth();
11001 Math.Round(hpResult);
11002 SetHealth("", "Health", hpResult);
11003
11004 AddQuantity(quantity_used);
11005 other_item.AddQuantity(-quantity_used);
11006 }
11007 }
11008 OnCombine(other_item);
11009 }
11010
11011 void OnCombine(ItemBase other_item)
11012 {
11013 #ifdef SERVER
11014 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11015 GetHierarchyParent().IncreaseLifetimeUp();
11016 #endif
11017 };
11018
11019 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11020 {
11021 PlayerBase p = PlayerBase.Cast(player);
11022
11023 array<int> recipesIds = p.m_Recipes;
11024 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11025 if (moduleRecipesManager)
11026 {
11027 EntityAI itemInHands = player.GetEntityInHands();
11028 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11029 }
11030
11031 for (int i = 0;i < recipesIds.Count(); i++)
11032 {
11033 int key = recipesIds.Get(i);
11034 string recipeName = moduleRecipesManager.GetRecipeName(key);
11035 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11036 }
11037 }
11038
11039 // -------------------------------------------------------------------------
11040 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11041 {
11042 super.GetDebugActions(outputList);
11043
11044 //quantity
11045 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11046 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11047 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11048 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11049 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11050
11051 //health
11052 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
11053 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
11054 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
11055 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11056 //temperature
11057 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
11058 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
11059 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
11060 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11061
11062 //wet
11063 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
11064 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
11065 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11066
11067 //liquidtype
11068 if (IsLiquidContainer())
11069 {
11070 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
11071 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
11072 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11073 }
11074
11075 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
11076 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11077
11078 // watch
11079 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
11080 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
11081 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11082
11083 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
11084
11085 InventoryLocation loc = new InventoryLocation();
11086 GetInventory().GetCurrentInventoryLocation(loc);
11087 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11088 {
11089 if (Gizmo_IsSupported())
11090 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11091 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11092 }
11093
11094 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11095 }
11096
11097 // -------------------------------------------------------------------------
11098 // -------------------------------------------------------------------------
11099 // -------------------------------------------------------------------------
11100 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11101 {
11102 super.OnAction(action_id, player, ctx);
11103
11104 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
11105 {
11106 switch (action_id)
11107 {
11108 case EActions.GIZMO_OBJECT:
11109 if (GetGizmoApi())
11110 GetGizmoApi().SelectObject(this);
11111 return true;
11112 case EActions.GIZMO_PHYSICS:
11113 if (GetGizmoApi())
11114 GetGizmoApi().SelectPhysics(GetPhysics());
11115 return true;
11116 }
11117 }
11118
11119 if (g_Game.IsServer())
11120 {
11121 switch (action_id)
11122 {
11123 case EActions.DELETE:
11124 Delete();
11125 return true;
11126 }
11127 }
11128
11129 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11130 {
11131 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11132 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11133 PlayerBase p = PlayerBase.Cast(player);
11134 if (EActions.RECIPES_RANGE_START < 1000)
11135 {
11136 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11137 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11138 }
11139 }
11140 #ifndef SERVER
11141 else if (action_id == EActions.WATCH_PLAYER)
11142 {
11143 PluginDeveloper.SetDeveloperItemClientEx(player);
11144 }
11145 #endif
11146 if (g_Game.IsServer())
11147 {
11148 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11149 {
11150 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11151 OnDebugButtonPressServer(id + 1);
11152 }
11153
11154 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11155 {
11156 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11157 InsertAgent(agent_id,100);
11158 }
11159
11160 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11161 {
11162 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11163 RemoveAgent(agent_id2);
11164 }
11165
11166 else if (action_id == EActions.ADD_QUANTITY)
11167 {
11168 if (IsMagazine())
11169 {
11170 Magazine mag = Magazine.Cast(this);
11171 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11172 }
11173 else
11174 {
11175 AddQuantity(GetQuantityMax() * 0.2);
11176 }
11177
11178 if (m_EM)
11179 {
11180 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11181 }
11182 //PrintVariables();
11183 }
11184
11185 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11186 {
11187 if (IsMagazine())
11188 {
11189 Magazine mag2 = Magazine.Cast(this);
11190 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11191 }
11192 else
11193 {
11194 AddQuantity(- GetQuantityMax() * 0.2);
11195 }
11196 if (m_EM)
11197 {
11198 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11199 }
11200 //PrintVariables();
11201 }
11202
11203 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11204 {
11205 SetQuantity(0);
11206
11207 if (m_EM)
11208 {
11209 m_EM.SetEnergy(0);
11210 }
11211 }
11212
11213 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11214 {
11216
11217 if (m_EM)
11218 {
11219 m_EM.SetEnergy(m_EM.GetEnergyMax());
11220 }
11221 }
11222
11223 else if (action_id == EActions.ADD_HEALTH)
11224 {
11225 AddHealth("","",GetMaxHealth("","Health")/5);
11226 }
11227 else if (action_id == EActions.REMOVE_HEALTH)
11228 {
11229 AddHealth("","",-GetMaxHealth("","Health")/5);
11230 }
11231 else if (action_id == EActions.DESTROY_HEALTH)
11232 {
11233 SetHealth01("","",0);
11234 }
11235 else if (action_id == EActions.WATCH_ITEM)
11236 {
11238 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11239 #ifdef DEVELOPER
11240 SetDebugDeveloper_item(this);
11241 #endif
11242 }
11243
11244 else if (action_id == EActions.ADD_TEMPERATURE)
11245 {
11246 AddTemperature(20);
11247 //PrintVariables();
11248 }
11249
11250 else if (action_id == EActions.REMOVE_TEMPERATURE)
11251 {
11252 AddTemperature(-20);
11253 //PrintVariables();
11254 }
11255
11256 else if (action_id == EActions.FLIP_FROZEN)
11257 {
11258 SetFrozen(!GetIsFrozen());
11259 //PrintVariables();
11260 }
11261
11262 else if (action_id == EActions.ADD_WETNESS)
11263 {
11264 AddWet(GetWetMax()/5);
11265 //PrintVariables();
11266 }
11267
11268 else if (action_id == EActions.REMOVE_WETNESS)
11269 {
11270 AddWet(-GetWetMax()/5);
11271 //PrintVariables();
11272 }
11273
11274 else if (action_id == EActions.LIQUIDTYPE_UP)
11275 {
11276 int curr_type = GetLiquidType();
11277 SetLiquidType(curr_type * 2);
11278 //AddWet(1);
11279 //PrintVariables();
11280 }
11281
11282 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11283 {
11284 int curr_type2 = GetLiquidType();
11285 SetLiquidType(curr_type2 / 2);
11286 }
11287
11288 else if (action_id == EActions.MAKE_SPECIAL)
11289 {
11290 auto debugParams = DebugSpawnParams.WithPlayer(player);
11291 OnDebugSpawnEx(debugParams);
11292 }
11293
11294 }
11295
11296
11297 return false;
11298 }
11299
11300 // -------------------------------------------------------------------------
11301
11302
11305 void OnActivatedByTripWire();
11306
11308 void OnActivatedByItem(notnull ItemBase item);
11309
11310 //----------------------------------------------------------------
11311 //returns true if item is able to explode when put in fire
11312 bool CanExplodeInFire()
11313 {
11314 return false;
11315 }
11316
11317 //----------------------------------------------------------------
11318 bool CanEat()
11319 {
11320 return true;
11321 }
11322
11323 //----------------------------------------------------------------
11324 override bool IsIgnoredByConstruction()
11325 {
11326 return true;
11327 }
11328
11329 //----------------------------------------------------------------
11330 //has FoodStages in config?
11331 bool HasFoodStage()
11332 {
11333 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11334 return g_Game.ConfigIsExisting(config_path);
11335 }
11336
11338 FoodStage GetFoodStage()
11339 {
11340 return null;
11341 }
11342
11343 bool CanBeCooked()
11344 {
11345 return false;
11346 }
11347
11348 bool CanBeCookedOnStick()
11349 {
11350 return false;
11351 }
11352
11354 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11356
11357 //----------------------------------------------------------------
11358 bool CanRepair(ItemBase item_repair_kit)
11359 {
11360 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11361 return module_repairing.CanRepair(this, item_repair_kit);
11362 }
11363
11364 //----------------------------------------------------------------
11365 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11366 {
11367 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11368 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11369 }
11370
11371 //----------------------------------------------------------------
11372 int GetItemSize()
11373 {
11374 /*
11375 vector v_size = this.ConfigGetVector("itemSize");
11376 int v_size_x = v_size[0];
11377 int v_size_y = v_size[1];
11378 int size = v_size_x * v_size_y;
11379 return size;
11380 */
11381
11382 return 1;
11383 }
11384
11385 //----------------------------------------------------------------
11386 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11387 bool CanBeMovedOverride()
11388 {
11389 return m_CanBeMovedOverride;
11390 }
11391
11392 //----------------------------------------------------------------
11393 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11394 void SetCanBeMovedOverride(bool setting)
11395 {
11396 m_CanBeMovedOverride = setting;
11397 }
11398
11399 //----------------------------------------------------------------
11407 void MessageToOwnerStatus(string text)
11408 {
11409 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11410
11411 if (player)
11412 {
11413 player.MessageStatus(text);
11414 }
11415 }
11416
11417 //----------------------------------------------------------------
11425 void MessageToOwnerAction(string text)
11426 {
11427 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11428
11429 if (player)
11430 {
11431 player.MessageAction(text);
11432 }
11433 }
11434
11435 //----------------------------------------------------------------
11443 void MessageToOwnerFriendly(string text)
11444 {
11445 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11446
11447 if (player)
11448 {
11449 player.MessageFriendly(text);
11450 }
11451 }
11452
11453 //----------------------------------------------------------------
11461 void MessageToOwnerImportant(string text)
11462 {
11463 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11464
11465 if (player)
11466 {
11467 player.MessageImportant(text);
11468 }
11469 }
11470
11471 override bool IsItemBase()
11472 {
11473 return true;
11474 }
11475
11476 // Checks if item is of questioned kind
11477 override bool KindOf(string tag)
11478 {
11479 bool found = false;
11480 string item_name = this.GetType();
11481 ref TStringArray item_tag_array = new TStringArray;
11482 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11483
11484 int array_size = item_tag_array.Count();
11485 for (int i = 0; i < array_size; i++)
11486 {
11487 if (item_tag_array.Get(i) == tag)
11488 {
11489 found = true;
11490 break;
11491 }
11492 }
11493 return found;
11494 }
11495
11496
11497 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11498 {
11499 //Debug.Log("OnRPC called");
11500 super.OnRPC(sender, rpc_type,ctx);
11501
11502 //Play soundset for attachment locking (ActionLockAttachment.c)
11503 switch (rpc_type)
11504 {
11505 #ifndef SERVER
11506 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11507 Param2<bool, string> p = new Param2<bool, string>(false, "");
11508
11509 if (!ctx.Read(p))
11510 return;
11511
11512 bool play = p.param1;
11513 string soundSet = p.param2;
11514
11515 if (play)
11516 {
11517 if (m_LockingSound)
11518 {
11520 {
11521 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11522 }
11523 }
11524 else
11525 {
11526 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11527 }
11528 }
11529 else
11530 {
11531 SEffectManager.DestroyEffect(m_LockingSound);
11532 }
11533
11534 break;
11535 #endif
11536
11537 }
11538
11539 if (GetWrittenNoteData())
11540 {
11541 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11542 }
11543 }
11544
11545 //-----------------------------
11546 // VARIABLE MANIPULATION SYSTEM
11547 //-----------------------------
11548 int NameToID(string name)
11549 {
11550 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11551 return plugin.GetID(name);
11552 }
11553
11554 string IDToName(int id)
11555 {
11556 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11557 return plugin.GetName(id);
11558 }
11559
11561 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11562 {
11563 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11564 //read the flags
11565 int varFlags;
11566 if (!ctx.Read(varFlags))
11567 return;
11568
11569 if (varFlags & ItemVariableFlags.FLOAT)
11570 {
11571 ReadVarsFromCTX(ctx);
11572 }
11573 }
11574
11575 override void SerializeNumericalVars(array<float> floats_out)
11576 {
11577 //some variables handled on EntityAI level already!
11578 super.SerializeNumericalVars(floats_out);
11579
11580 // the order of serialization must be the same as the order of de-serialization
11581 //--------------------------------------------
11582 if (IsVariableSet(VARIABLE_QUANTITY))
11583 {
11584 floats_out.Insert(m_VarQuantity);
11585 }
11586 //--------------------------------------------
11587 if (IsVariableSet(VARIABLE_WET))
11588 {
11589 floats_out.Insert(m_VarWet);
11590 }
11591 //--------------------------------------------
11592 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11593 {
11594 floats_out.Insert(m_VarLiquidType);
11595 }
11596 //--------------------------------------------
11597 if (IsVariableSet(VARIABLE_COLOR))
11598 {
11599 floats_out.Insert(m_ColorComponentR);
11600 floats_out.Insert(m_ColorComponentG);
11601 floats_out.Insert(m_ColorComponentB);
11602 floats_out.Insert(m_ColorComponentA);
11603 }
11604 //--------------------------------------------
11605 if (IsVariableSet(VARIABLE_CLEANNESS))
11606 {
11607 floats_out.Insert(m_Cleanness);
11608 }
11609 }
11610
11611 override void DeSerializeNumericalVars(array<float> floats)
11612 {
11613 //some variables handled on EntityAI level already!
11614 super.DeSerializeNumericalVars(floats);
11615
11616 // the order of serialization must be the same as the order of de-serialization
11617 int index = 0;
11618 int mask = Math.Round(floats.Get(index));
11619
11620 index++;
11621 //--------------------------------------------
11622 if (mask & VARIABLE_QUANTITY)
11623 {
11624 if (m_IsStoreLoad)
11625 {
11626 SetStoreLoadedQuantity(floats.Get(index));
11627 }
11628 else
11629 {
11630 float quantity = floats.Get(index);
11631 SetQuantity(quantity, true, false, false, false);
11632 }
11633 index++;
11634 }
11635 //--------------------------------------------
11636 if (mask & VARIABLE_WET)
11637 {
11638 float wet = floats.Get(index);
11639 SetWet(wet);
11640 index++;
11641 }
11642 //--------------------------------------------
11643 if (mask & VARIABLE_LIQUIDTYPE)
11644 {
11645 int liquidtype = Math.Round(floats.Get(index));
11646 SetLiquidType(liquidtype);
11647 index++;
11648 }
11649 //--------------------------------------------
11650 if (mask & VARIABLE_COLOR)
11651 {
11652 m_ColorComponentR = Math.Round(floats.Get(index));
11653 index++;
11654 m_ColorComponentG = Math.Round(floats.Get(index));
11655 index++;
11656 m_ColorComponentB = Math.Round(floats.Get(index));
11657 index++;
11658 m_ColorComponentA = Math.Round(floats.Get(index));
11659 index++;
11660 }
11661 //--------------------------------------------
11662 if (mask & VARIABLE_CLEANNESS)
11663 {
11664 int cleanness = Math.Round(floats.Get(index));
11665 SetCleanness(cleanness);
11666 index++;
11667 }
11668 }
11669
11670 override void WriteVarsToCTX(ParamsWriteContext ctx)
11671 {
11672 super.WriteVarsToCTX(ctx);
11673
11674 //--------------------------------------------
11675 if (IsVariableSet(VARIABLE_QUANTITY))
11676 {
11677 ctx.Write(GetQuantity());
11678 }
11679 //--------------------------------------------
11680 if (IsVariableSet(VARIABLE_WET))
11681 {
11682 ctx.Write(GetWet());
11683 }
11684 //--------------------------------------------
11685 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11686 {
11687 ctx.Write(GetLiquidType());
11688 }
11689 //--------------------------------------------
11690 if (IsVariableSet(VARIABLE_COLOR))
11691 {
11692 int r,g,b,a;
11693 GetColor(r,g,b,a);
11694 ctx.Write(r);
11695 ctx.Write(g);
11696 ctx.Write(b);
11697 ctx.Write(a);
11698 }
11699 //--------------------------------------------
11700 if (IsVariableSet(VARIABLE_CLEANNESS))
11701 {
11702 ctx.Write(GetCleanness());
11703 }
11704 }
11705
11706 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11707 {
11708 if (!super.ReadVarsFromCTX(ctx,version))
11709 return false;
11710
11711 int intValue;
11712 float value;
11713
11714 if (version < 140)
11715 {
11716 if (!ctx.Read(intValue))
11717 return false;
11718
11719 m_VariablesMask = intValue;
11720 }
11721
11722 if (m_VariablesMask & VARIABLE_QUANTITY)
11723 {
11724 if (!ctx.Read(value))
11725 return false;
11726
11727 if (IsStoreLoad())
11728 {
11730 }
11731 else
11732 {
11733 SetQuantity(value, true, false, false, false);
11734 }
11735 }
11736 //--------------------------------------------
11737 if (version < 140)
11738 {
11739 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11740 {
11741 if (!ctx.Read(value))
11742 return false;
11743 SetTemperatureDirect(value);
11744 }
11745 }
11746 //--------------------------------------------
11747 if (m_VariablesMask & VARIABLE_WET)
11748 {
11749 if (!ctx.Read(value))
11750 return false;
11751 SetWet(value);
11752 }
11753 //--------------------------------------------
11754 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11755 {
11756 if (!ctx.Read(intValue))
11757 return false;
11758 SetLiquidType(intValue);
11759 }
11760 //--------------------------------------------
11761 if (m_VariablesMask & VARIABLE_COLOR)
11762 {
11763 int r,g,b,a;
11764 if (!ctx.Read(r))
11765 return false;
11766 if (!ctx.Read(g))
11767 return false;
11768 if (!ctx.Read(b))
11769 return false;
11770 if (!ctx.Read(a))
11771 return false;
11772
11773 SetColor(r,g,b,a);
11774 }
11775 //--------------------------------------------
11776 if (m_VariablesMask & VARIABLE_CLEANNESS)
11777 {
11778 if (!ctx.Read(intValue))
11779 return false;
11780 SetCleanness(intValue);
11781 }
11782 //--------------------------------------------
11783 if (version >= 138 && version < 140)
11784 {
11785 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11786 {
11787 if (!ctx.Read(intValue))
11788 return false;
11789 SetFrozen(intValue);
11790 }
11791 }
11792
11793 return true;
11794 }
11795
11796 //----------------------------------------------------------------
11797 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11798 {
11799 m_IsStoreLoad = true;
11801 {
11802 m_FixDamageSystemInit = true;
11803 }
11804
11805 if (!super.OnStoreLoad(ctx, version))
11806 {
11807 m_IsStoreLoad = false;
11808 return false;
11809 }
11810
11811 if (version >= 114)
11812 {
11813 bool hasQuickBarIndexSaved;
11814
11815 if (!ctx.Read(hasQuickBarIndexSaved))
11816 {
11817 m_IsStoreLoad = false;
11818 return false;
11819 }
11820
11821 if (hasQuickBarIndexSaved)
11822 {
11823 int itmQBIndex;
11824
11825 //Load quickbar item bind
11826 if (!ctx.Read(itmQBIndex))
11827 {
11828 m_IsStoreLoad = false;
11829 return false;
11830 }
11831
11832 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11833 if (itmQBIndex != -1 && parentPlayer)
11834 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11835 }
11836 }
11837 else
11838 {
11839 // Backup of how it used to be
11840 PlayerBase player;
11841 int itemQBIndex;
11842 if (version == int.MAX)
11843 {
11844 if (!ctx.Read(itemQBIndex))
11845 {
11846 m_IsStoreLoad = false;
11847 return false;
11848 }
11849 }
11850 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11851 {
11852 //Load quickbar item bind
11853 if (!ctx.Read(itemQBIndex))
11854 {
11855 m_IsStoreLoad = false;
11856 return false;
11857 }
11858 if (itemQBIndex != -1 && player)
11859 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11860 }
11861 }
11862
11863 if (version < 140)
11864 {
11865 // variable management system
11866 if (!LoadVariables(ctx, version))
11867 {
11868 m_IsStoreLoad = false;
11869 return false;
11870 }
11871 }
11872
11873 //agent trasmission system
11874 if (!LoadAgents(ctx, version))
11875 {
11876 m_IsStoreLoad = false;
11877 return false;
11878 }
11879 if (version >= 132)
11880 {
11881 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11882 if (raib)
11883 {
11884 if (!raib.OnStoreLoad(ctx,version))
11885 {
11886 m_IsStoreLoad = false;
11887 return false;
11888 }
11889 }
11890 }
11891
11892 m_IsStoreLoad = false;
11893 return true;
11894 }
11895
11896 //----------------------------------------------------------------
11897
11898 override void OnStoreSave(ParamsWriteContext ctx)
11899 {
11900 super.OnStoreSave(ctx);
11901
11902 PlayerBase player;
11903 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11904 {
11905 ctx.Write(true); // Keep track of if we should actually read this in or not
11906 //Save quickbar item bind
11907 int itemQBIndex = -1;
11908 itemQBIndex = player.FindQuickBarEntityIndex(this);
11909 ctx.Write(itemQBIndex);
11910 }
11911 else
11912 {
11913 ctx.Write(false); // Keep track of if we should actually read this in or not
11914 }
11915
11916 SaveAgents(ctx);//agent trasmission system
11917
11918 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11919 if (raib)
11920 {
11921 raib.OnStoreSave(ctx);
11922 }
11923 }
11924 //----------------------------------------------------------------
11925
11926 override void AfterStoreLoad()
11927 {
11928 super.AfterStoreLoad();
11929
11931 {
11933 }
11934
11935 if (GetStoreLoadedQuantity() != float.LOWEST)
11936 {
11938 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
11939 }
11940 }
11941
11942 override void EEOnAfterLoad()
11943 {
11944 super.EEOnAfterLoad();
11945
11947 {
11948 m_FixDamageSystemInit = false;
11949 }
11950
11953 }
11954
11955 bool CanBeDisinfected()
11956 {
11957 return false;
11958 }
11959
11960
11961 //----------------------------------------------------------------
11962 override void OnVariablesSynchronized()
11963 {
11964 if (m_Initialized)
11965 {
11966 #ifdef PLATFORM_CONSOLE
11967 //bruteforce it is
11968 if (IsSplitable())
11969 {
11970 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
11971 if (menu)
11972 {
11973 menu.Refresh();
11974 }
11975 }
11976 #endif
11977 }
11978
11980 {
11981 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
11982 m_WantPlayImpactSound = false;
11983 }
11984
11986 {
11987 SetWeightDirty();
11989 }
11990 if (m_VarWet != m_VarWetPrev)
11991 {
11994 }
11995
11996 if (m_SoundSyncPlay != 0)
11997 {
12000
12001 m_SoundSyncPlay = 0;
12002 m_SoundSyncSlotID = -1;
12003 }
12004 if (m_SoundSyncStop != 0)
12005 {
12007 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12008 m_SoundSyncStop = 0;
12009 }
12010
12011 super.OnVariablesSynchronized();
12012 }
12013
12014 //------------------------- Quantity
12015 //----------------------------------------------------------------
12017 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12018 {
12019 if (!IsServerCheck(allow_client))
12020 return false;
12021
12022 if (!HasQuantity())
12023 return false;
12024
12025 float min = GetQuantityMin();
12026 float max = GetQuantityMax();
12027
12028 if (value <= (min + 0.001))
12029 value = min;
12030
12031 if (value == min)
12032 {
12033 if (destroy_config)
12034 {
12035 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12036 if (dstr)
12037 {
12038 m_VarQuantity = Math.Clamp(value, min, max);
12039 this.Delete();
12040 return true;
12041 }
12042 }
12043 else if (destroy_forced)
12044 {
12045 m_VarQuantity = Math.Clamp(value, min, max);
12046 this.Delete();
12047 return true;
12048 }
12049 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12050 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12051 }
12052
12053 float delta = m_VarQuantity;
12054 m_VarQuantity = Math.Clamp(value, min, max);
12055
12056 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12057 {
12058 EntityAI parent = GetHierarchyRoot();
12059 InventoryLocation iLoc = new InventoryLocation();
12060 GetInventory().GetCurrentInventoryLocation(iLoc);
12061 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
12062 {
12063 int iLocSlot = iLoc.GetSlot();
12064 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
12065 {
12066 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
12067 }
12068 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
12069 {
12070 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
12071 }
12072 }
12073 }
12074
12075 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
12076 {
12077 delta = m_VarQuantity - delta;
12078
12079 if (delta)
12080 OnQuantityChanged(delta);
12081 }
12082
12083 SetVariableMask(VARIABLE_QUANTITY);
12084
12085 return false;
12086 }
12087
12088 //----------------------------------------------------------------
12090 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
12091 {
12092 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
12093 }
12094 //----------------------------------------------------------------
12095 void SetQuantityMax()
12096 {
12097 float max = GetQuantityMax();
12098 SetQuantity(max);
12099 }
12100
12101 override void SetQuantityToMinimum()
12102 {
12103 float min = GetQuantityMin();
12104 SetQuantity(min);
12105 }
12106 //----------------------------------------------------------------
12108 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
12109 {
12110 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
12111 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
12112 SetQuantity(result, destroy_config, destroy_forced);
12113 }
12114
12115 //----------------------------------------------------------------
12117 override float GetQuantityNormalized()
12118 {
12119 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12120 }
12121
12123 {
12124 return GetQuantityNormalized();
12125 }
12126
12127 /*void SetAmmoNormalized(float value)
12128 {
12129 float value_clamped = Math.Clamp(value, 0, 1);
12130 Magazine this_mag = Magazine.Cast(this);
12131 int max_rounds = this_mag.GetAmmoMax();
12132 int result = value * max_rounds;//can the rounded if higher precision is required
12133 this_mag.SetAmmoCount(result);
12134 }*/
12135 //----------------------------------------------------------------
12136 override int GetQuantityMax()
12137 {
12138 int slot = -1;
12139 GameInventory inventory = GetInventory();
12140 if (inventory)
12141 {
12142 InventoryLocation il = new InventoryLocation;
12143 inventory.GetCurrentInventoryLocation(il);
12144 slot = il.GetSlot();
12145 }
12146
12147 return GetTargetQuantityMax(slot);
12148 }
12149
12150 override int GetTargetQuantityMax(int attSlotID = -1)
12151 {
12152 float quantity_max = 0;
12153
12154 if (IsSplitable()) //only stackable/splitable items can check for stack size
12155 {
12156 if (attSlotID != -1)
12157 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12158
12159 if (quantity_max <= 0)
12160 quantity_max = m_VarStackMax;
12161 }
12162
12163 if (quantity_max <= 0)
12164 quantity_max = m_VarQuantityMax;
12165
12166 return quantity_max;
12167 }
12168 //----------------------------------------------------------------
12169 override int GetQuantityMin()
12170 {
12171 return m_VarQuantityMin;
12172 }
12173 //----------------------------------------------------------------
12174 int GetQuantityInit()
12175 {
12176 return m_VarQuantityInit;
12177 }
12178
12179 //----------------------------------------------------------------
12180 override bool HasQuantity()
12181 {
12182 return !(GetQuantityMax() - GetQuantityMin() == 0);
12183 }
12184
12185 override float GetQuantity()
12186 {
12187 return m_VarQuantity;
12188 }
12189
12190 bool IsFullQuantity()
12191 {
12192 return GetQuantity() >= GetQuantityMax();
12193 }
12194
12195 //Calculates weight of single item without attachments and cargo
12196 override float GetSingleInventoryItemWeightEx()
12197 {
12198 //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
12199 float weightEx = GetWeightEx();//overall weight of the item
12200 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12201 return weightEx - special;
12202 }
12203
12204 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12206 {
12208 }
12209
12210 override protected float GetWeightSpecialized(bool forceRecalc = false)
12211 {
12212 if (IsSplitable()) //quantity determines size of the stack
12213 {
12214 #ifdef DEVELOPER
12215 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12216 {
12217 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12218 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12219 }
12220 #endif
12221
12222 return GetQuantity() * GetConfigWeightModified();
12223 }
12224 else if (HasEnergyManager())// items with energy manager
12225 {
12226 #ifdef DEVELOPER
12227 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12228 {
12229 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12230 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12231 }
12232 #endif
12233 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12234 }
12235 else//everything else
12236 {
12237 #ifdef DEVELOPER
12238 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12239 {
12240 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12241 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12242 }
12243 #endif
12244 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12245 }
12246 }
12247
12249 int GetNumberOfItems()
12250 {
12251 int item_count = 0;
12252 ItemBase item;
12253
12254 GameInventory inventory = GetInventory();
12255 CargoBase cargo = inventory.GetCargo();
12256 if (cargo != NULL)
12257 {
12258 item_count = cargo.GetItemCount();
12259 }
12260
12261 int nAttachments = inventory.AttachmentCount();
12262 for (int i = 0; i < nAttachments; ++i)
12263 {
12264 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
12265 if (item)
12266 item_count += item.GetNumberOfItems();
12267 }
12268 return item_count;
12269 }
12270
12272 float GetUnitWeight(bool include_wetness = true)
12273 {
12274 float weight = 0;
12275 float wetness = 1;
12276 if (include_wetness)
12277 wetness += GetWet();
12278 if (IsSplitable()) //quantity determines size of the stack
12279 {
12280 weight = wetness * m_ConfigWeight;
12281 }
12282 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12283 {
12284 weight = 1;
12285 }
12286 return weight;
12287 }
12288
12289 //-----------------------------------------------------------------
12290
12291 override void ClearInventory()
12292 {
12293 GameInventory inventory = GetInventory();
12294 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
12295 {
12296 array<EntityAI> items = new array<EntityAI>;
12297 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
12298 for (int i = 0; i < items.Count(); ++i)
12299 {
12300 ItemBase item = ItemBase.Cast(items.Get(i));
12301 if (item)
12302 {
12303 g_Game.ObjectDelete(item);
12304 }
12305 }
12306 }
12307 }
12308
12309 //------------------------- Energy
12310
12311 //----------------------------------------------------------------
12312 float GetEnergy()
12313 {
12314 float energy = 0;
12315 if (HasEnergyManager())
12316 {
12317 energy = GetCompEM().GetEnergy();
12318 }
12319 return energy;
12320 }
12321
12322
12323 override void OnEnergyConsumed()
12324 {
12325 super.OnEnergyConsumed();
12326
12328 }
12329
12330 override void OnEnergyAdded()
12331 {
12332 super.OnEnergyAdded();
12333
12335 }
12336
12337 // Converts energy (from Energy Manager) to quantity, if enabled.
12339 {
12340 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12341 {
12342 if (HasQuantity())
12343 {
12344 float energy_0to1 = GetCompEM().GetEnergy0To1();
12345 SetQuantityNormalized(energy_0to1);
12346 }
12347 }
12348 }
12349
12350 //----------------------------------------------------------------
12351 float GetHeatIsolationInit()
12352 {
12353 return ConfigGetFloat("heatIsolation");
12354 }
12355
12356 float GetHeatIsolation()
12357 {
12358 return m_HeatIsolation;
12359 }
12360
12361 float GetDryingIncrement(string pIncrementName)
12362 {
12363 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12364 if (g_Game.ConfigIsExisting(paramPath))
12365 return g_Game.ConfigGetFloat(paramPath);
12366
12367 return 0.0;
12368 }
12369
12370 float GetSoakingIncrement(string pIncrementName)
12371 {
12372 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12373 if (g_Game.ConfigIsExisting(paramPath))
12374 return g_Game.ConfigGetFloat(paramPath);
12375
12376 return 0.0;
12377 }
12378 //----------------------------------------------------------------
12379 override void SetWet(float value, bool allow_client = false)
12380 {
12381 if (!IsServerCheck(allow_client))
12382 return;
12383
12384 float min = GetWetMin();
12385 float max = GetWetMax();
12386
12387 float previousValue = m_VarWet;
12388
12389 m_VarWet = Math.Clamp(value, min, max);
12390
12391 if (previousValue != m_VarWet)
12392 {
12393 SetVariableMask(VARIABLE_WET);
12394 OnWetChanged(m_VarWet, previousValue);
12395 }
12396 }
12397 //----------------------------------------------------------------
12398 override void AddWet(float value)
12399 {
12400 SetWet(GetWet() + value);
12401 }
12402 //----------------------------------------------------------------
12403 override void SetWetMax()
12404 {
12406 }
12407 //----------------------------------------------------------------
12408 override float GetWet()
12409 {
12410 return m_VarWet;
12411 }
12412 //----------------------------------------------------------------
12413 override float GetWetMax()
12414 {
12415 return m_VarWetMax;
12416 }
12417 //----------------------------------------------------------------
12418 override float GetWetMin()
12419 {
12420 return m_VarWetMin;
12421 }
12422 //----------------------------------------------------------------
12423 override float GetWetInit()
12424 {
12425 return m_VarWetInit;
12426 }
12427 //----------------------------------------------------------------
12428 override void OnWetChanged(float newVal, float oldVal)
12429 {
12430 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12431 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12432 if (newLevel != oldLevel)
12433 {
12434 OnWetLevelChanged(newLevel,oldLevel);
12435 }
12436 }
12437
12438 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12439 {
12440 SetWeightDirty();
12441 }
12442
12443 override EWetnessLevel GetWetLevel()
12444 {
12445 return GetWetLevelInternal(m_VarWet);
12446 }
12447
12448 //----------------------------------------------------------------
12449
12450 override void SetStoreLoad(bool value)
12451 {
12452 m_IsStoreLoad = value;
12453 }
12454
12455 override bool IsStoreLoad()
12456 {
12457 return m_IsStoreLoad;
12458 }
12459
12460 override void SetStoreLoadedQuantity(float value)
12461 {
12462 m_StoreLoadedQuantity = value;
12463 }
12464
12465 override float GetStoreLoadedQuantity()
12466 {
12467 return m_StoreLoadedQuantity;
12468 }
12469
12470 //----------------------------------------------------------------
12471
12472 float GetItemModelLength()
12473 {
12474 if (ConfigIsExisting("itemModelLength"))
12475 {
12476 return ConfigGetFloat("itemModelLength");
12477 }
12478 return 0;
12479 }
12480
12481 float GetItemAttachOffset()
12482 {
12483 if (ConfigIsExisting("itemAttachOffset"))
12484 {
12485 return ConfigGetFloat("itemAttachOffset");
12486 }
12487 return 0;
12488 }
12489
12490 override void SetCleanness(int value, bool allow_client = false)
12491 {
12492 if (!IsServerCheck(allow_client))
12493 return;
12494
12495 int previousValue = m_Cleanness;
12496
12497 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12498
12499 if (previousValue != m_Cleanness)
12500 SetVariableMask(VARIABLE_CLEANNESS);
12501 }
12502
12503 override int GetCleanness()
12504 {
12505 return m_Cleanness;
12506 }
12507
12509 {
12510 return true;
12511 }
12512
12513 //----------------------------------------------------------------
12514 // ATTACHMENT LOCKING
12515 // Getters relevant to generic ActionLockAttachment
12516 int GetLockType()
12517 {
12518 return m_LockType;
12519 }
12520
12521 string GetLockSoundSet()
12522 {
12523 return m_LockSoundSet;
12524 }
12525
12526 //----------------------------------------------------------------
12527 //------------------------- Color
12528 // sets items color variable given color components
12529 override void SetColor(int r, int g, int b, int a)
12530 {
12535 SetVariableMask(VARIABLE_COLOR);
12536 }
12538 override void GetColor(out int r,out int g,out int b,out int a)
12539 {
12544 }
12545
12546 bool IsColorSet()
12547 {
12548 return IsVariableSet(VARIABLE_COLOR);
12549 }
12550
12552 string GetColorString()
12553 {
12554 int r,g,b,a;
12555 GetColor(r,g,b,a);
12556 r = r/255;
12557 g = g/255;
12558 b = b/255;
12559 a = a/255;
12560 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12561 }
12562 //----------------------------------------------------------------
12563 //------------------------- LiquidType
12564
12565 override void SetLiquidType(int value, bool allow_client = false)
12566 {
12567 if (!IsServerCheck(allow_client))
12568 return;
12569
12570 int old = m_VarLiquidType;
12571 m_VarLiquidType = value;
12572 OnLiquidTypeChanged(old,value);
12573 SetVariableMask(VARIABLE_LIQUIDTYPE);
12574 }
12575
12576 int GetLiquidTypeInit()
12577 {
12578 return ConfigGetInt("varLiquidTypeInit");
12579 }
12580
12581 override int GetLiquidType()
12582 {
12583 return m_VarLiquidType;
12584 }
12585
12586 protected void OnLiquidTypeChanged(int oldType, int newType)
12587 {
12588 if (newType == LIQUID_NONE && GetIsFrozen())
12589 SetFrozen(false);
12590 }
12591
12593 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12594 {
12595 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12596 }
12597
12598 // -------------------------------------------------------------------------
12600 void OnInventoryEnter(Man player)
12601 {
12602 PlayerBase nplayer;
12603 if (PlayerBase.CastTo(nplayer, player))
12604 {
12605 m_CanPlayImpactSound = true;
12606 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12607 }
12608 }
12609
12610 // -------------------------------------------------------------------------
12612 void OnInventoryExit(Man player)
12613 {
12614 PlayerBase nplayer;
12615 if (PlayerBase.CastTo(nplayer,player))
12616 {
12617 nplayer.SetEnableQuickBarEntityShortcut(this, false);
12618 }
12619
12620 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12621
12622 if (HasEnergyManager())
12623 {
12624 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12625 }
12626 }
12627
12628 // ADVANCED PLACEMENT EVENTS
12629 override void OnPlacementStarted(Man player)
12630 {
12631 super.OnPlacementStarted(player);
12632
12633 SetTakeable(false);
12634 }
12635
12636 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12637 {
12638 if (m_AdminLog)
12639 {
12640 m_AdminLog.OnPlacementComplete(player, this);
12641 }
12642
12643 super.OnPlacementComplete(player, position, orientation);
12644 }
12645
12646 //-----------------------------
12647 // AGENT SYSTEM
12648 //-----------------------------
12649 //--------------------------------------------------------------------------
12650 bool ContainsAgent(int agent_id)
12651 {
12652 if (agent_id & m_AttachedAgents)
12653 {
12654 return true;
12655 }
12656 else
12657 {
12658 return false;
12659 }
12660 }
12661
12662 //--------------------------------------------------------------------------
12663 override void RemoveAgent(int agent_id)
12664 {
12665 if (ContainsAgent(agent_id))
12666 {
12667 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12668 }
12669 }
12670
12671 //--------------------------------------------------------------------------
12672 override void RemoveAllAgents()
12673 {
12674 m_AttachedAgents = 0;
12675 }
12676 //--------------------------------------------------------------------------
12677 override void RemoveAllAgentsExcept(int agent_to_keep)
12678 {
12679 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12680 }
12681 // -------------------------------------------------------------------------
12682 override void InsertAgent(int agent, float count = 1)
12683 {
12684 if (count < 1)
12685 return;
12686 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12688 }
12689
12691 void TransferAgents(int agents)
12692 {
12694 }
12695
12696 // -------------------------------------------------------------------------
12697 override int GetAgents()
12698 {
12699 return m_AttachedAgents;
12700 }
12701 //----------------------------------------------------------------------
12702
12703 /*int GetContaminationType()
12704 {
12705 int contamination_type;
12706
12707 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12708 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12709 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12710 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12711
12712 Edible_Base edible = Edible_Base.Cast(this);
12713 int agents = GetAgents();
12714 if (edible)
12715 {
12716 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12717 if (profile)
12718 {
12719 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12720 }
12721 }
12722 if (agents & CONTAMINATED_MASK)
12723 {
12724 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12725 }
12726 if (agents & POISONED_MASK)
12727 {
12728 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12729 }
12730 if (agents & NERVE_GAS_MASK)
12731 {
12732 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12733 }
12734 if (agents & DIRTY_MASK)
12735 {
12736 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12737 }
12738
12739 return agents;
12740 }*/
12741
12742 // -------------------------------------------------------------------------
12743 bool LoadAgents(ParamsReadContext ctx, int version)
12744 {
12745 if (!ctx.Read(m_AttachedAgents))
12746 return false;
12747 return true;
12748 }
12749 // -------------------------------------------------------------------------
12751 {
12752
12754 }
12755 // -------------------------------------------------------------------------
12756
12758 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12759 {
12760 super.CheckForRoofLimited(timeTresholdMS);
12761
12762 float time = g_Game.GetTime();
12763 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12764 {
12765 m_PreviousRoofTestTime = time;
12766 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12767 }
12768 }
12769
12770 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12771 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12772 {
12773 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12774 {
12775 return 0;
12776 }
12777
12778 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12779 {
12780 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12781 if (filter)
12782 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12783 else
12784 return 0;//otherwise return 0 when no filter attached
12785 }
12786
12787 string subclassPath, entryName;
12788
12789 switch (type)
12790 {
12791 case DEF_BIOLOGICAL:
12792 entryName = "biological";
12793 break;
12794 case DEF_CHEMICAL:
12795 entryName = "chemical";
12796 break;
12797 default:
12798 entryName = "biological";
12799 break;
12800 }
12801
12802 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12803
12804 return g_Game.ConfigGetFloat(subclassPath + entryName);
12805 }
12806
12807
12808
12810 override void EEOnCECreate()
12811 {
12812 if (!IsMagazine())
12814
12816 }
12817
12818
12819 //-------------------------
12820 // OPEN/CLOSE USER ACTIONS
12821 //-------------------------
12823 void Open();
12824 void Close();
12825 bool IsOpen()
12826 {
12827 return true;
12828 }
12829
12830 override bool CanDisplayCargo()
12831 {
12832 return IsOpen();
12833 }
12834
12835
12836 // ------------------------------------------------------------
12837 // CONDITIONS
12838 // ------------------------------------------------------------
12839 override bool CanPutInCargo(EntityAI parent)
12840 {
12841 if (parent)
12842 {
12843 if (parent.IsInherited(DayZInfected))
12844 return true;
12845
12846 if (!parent.IsRuined())
12847 return true;
12848 }
12849
12850 return true;
12851 }
12852
12853 override bool CanPutAsAttachment(EntityAI parent)
12854 {
12855 if (!super.CanPutAsAttachment(parent))
12856 {
12857 return false;
12858 }
12859
12860 if (!IsRuined() && !parent.IsRuined())
12861 {
12862 return true;
12863 }
12864
12865 return false;
12866 }
12867
12868 override bool CanReceiveItemIntoCargo(EntityAI item)
12869 {
12870 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12871 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12872 // return false;
12873
12874 return super.CanReceiveItemIntoCargo(item);
12875 }
12876
12877 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12878 {
12879 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12880 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12881 // return false;
12882
12883 GameInventory attachmentInv = attachment.GetInventory();
12884 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12885 {
12886 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12887 return false;
12888 }
12889
12890 InventoryLocation loc = new InventoryLocation();
12891 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12892 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12893 return false;
12894
12895 return super.CanReceiveAttachment(attachment, slotId);
12896 }
12897
12898 override bool CanReleaseAttachment(EntityAI attachment)
12899 {
12900 if (!super.CanReleaseAttachment(attachment))
12901 return false;
12902
12903 return GetInventory().AreChildrenAccessible();
12904 }
12905
12906 /*override bool CanLoadAttachment(EntityAI attachment)
12907 {
12908 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12909 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12910 // return false;
12911
12912 GameInventory attachmentInv = attachment.GetInventory();
12913 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12914 {
12915 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12916 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12917
12918 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12919 return false;
12920 }
12921
12922 return super.CanLoadAttachment(attachment);
12923 }*/
12924
12925 // Plays muzzle flash particle effects
12926 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12927 {
12928 int id = muzzle_owner.GetMuzzleID();
12929 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12930
12931 if (WPOF_array)
12932 {
12933 for (int i = 0; i < WPOF_array.Count(); i++)
12934 {
12935 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12936
12937 if (WPOF)
12938 {
12939 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12940 }
12941 }
12942 }
12943 }
12944
12945 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12946 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12947 {
12948 int id = muzzle_owner.GetMuzzleID();
12949 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12950
12951 if (WPOBE_array)
12952 {
12953 for (int i = 0; i < WPOBE_array.Count(); i++)
12954 {
12955 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12956
12957 if (WPOBE)
12958 {
12959 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12960 }
12961 }
12962 }
12963 }
12964
12965 // Plays all weapon overheating particles
12966 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12967 {
12968 int id = muzzle_owner.GetMuzzleID();
12969 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12970
12971 if (WPOOH_array)
12972 {
12973 for (int i = 0; i < WPOOH_array.Count(); i++)
12974 {
12975 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12976
12977 if (WPOOH)
12978 {
12979 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12980 }
12981 }
12982 }
12983 }
12984
12985 // Updates all weapon overheating particles
12986 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12987 {
12988 int id = muzzle_owner.GetMuzzleID();
12989 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12990
12991 if (WPOOH_array)
12992 {
12993 for (int i = 0; i < WPOOH_array.Count(); i++)
12994 {
12995 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12996
12997 if (WPOOH)
12998 {
12999 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13000 }
13001 }
13002 }
13003 }
13004
13005 // Stops overheating particles
13006 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13007 {
13008 int id = muzzle_owner.GetMuzzleID();
13009 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13010
13011 if (WPOOH_array)
13012 {
13013 for (int i = 0; i < WPOOH_array.Count(); i++)
13014 {
13015 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13016
13017 if (WPOOH)
13018 {
13019 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13020 }
13021 }
13022 }
13023 }
13024
13025 //----------------------------------------------------------------
13026 //Item Behaviour - unified approach
13027 override bool IsHeavyBehaviour()
13028 {
13029 if (m_ItemBehaviour == 0)
13030 {
13031 return true;
13032 }
13033
13034 return false;
13035 }
13036
13037 override bool IsOneHandedBehaviour()
13038 {
13039 if (m_ItemBehaviour == 1)
13040 {
13041 return true;
13042 }
13043
13044 return false;
13045 }
13046
13047 override bool IsTwoHandedBehaviour()
13048 {
13049 if (m_ItemBehaviour == 2)
13050 {
13051 return true;
13052 }
13053
13054 return false;
13055 }
13056
13057 bool IsDeployable()
13058 {
13059 return false;
13060 }
13061
13063 float GetDeployTime()
13064 {
13065 return UATimeSpent.DEFAULT_DEPLOY;
13066 }
13067
13068
13069 //----------------------------------------------------------------
13070 // Item Targeting (User Actions)
13071 override void SetTakeable(bool pState)
13072 {
13073 m_IsTakeable = pState;
13074 SetSynchDirty();
13075 }
13076
13077 override bool IsTakeable()
13078 {
13079 return m_IsTakeable;
13080 }
13081
13082 // For cases where we want to show object widget which cant be taken to hands
13084 {
13085 return false;
13086 }
13087
13089 protected void PreLoadSoundAttachmentType()
13090 {
13091 string att_type = "None";
13092
13093 if (ConfigIsExisting("soundAttType"))
13094 {
13095 att_type = ConfigGetString("soundAttType");
13096 }
13097
13098 m_SoundAttType = att_type;
13099 }
13100
13101 override string GetAttachmentSoundType()
13102 {
13103 return m_SoundAttType;
13104 }
13105
13106 //----------------------------------------------------------------
13107 //SOUNDS - ItemSoundHandler
13108 //----------------------------------------------------------------
13109
13110 string GetPlaceSoundset(); // played when deploy starts
13111 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13112 string GetDeploySoundset(); // played when deploy sucessfully finishes
13113 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13114 string GetFoldSoundset(); // played when fold sucessfully finishes
13115
13117 {
13118 if (!m_ItemSoundHandler)
13120
13121 return m_ItemSoundHandler;
13122 }
13123
13124 // override to initialize sounds
13125 protected void InitItemSounds()
13126 {
13127 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
13128 return;
13129
13131
13132 if (GetPlaceSoundset() != string.Empty)
13133 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13134
13135 if (GetDeploySoundset() != string.Empty)
13136 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13137
13138 SoundParameters params = new SoundParameters();
13139 params.m_Loop = true;
13140 if (GetLoopDeploySoundset() != string.Empty)
13141 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13142 }
13143
13144 // Start sound using ItemSoundHandler
13145 void StartItemSoundServer(int id, int slotId)
13146 {
13147 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
13148 {
13149 m_SoundSyncSlotID = slotId;
13150 m_SoundSyncPlay = id;
13151
13152 SetSynchDirty();
13153
13154 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13155 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
13156 }
13157 }
13158
13159 void StartItemSoundServer(int id)
13160 {
13161 StartItemSoundServer(id, InventorySlots.INVALID);
13162 }
13163
13164 // Stop sound using ItemSoundHandler
13165 void StopItemSoundServer(int id)
13166 {
13167 if (!g_Game.IsServer())
13168 return;
13169
13170 m_SoundSyncStop = id;
13171 SetSynchDirty();
13172
13173 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13174 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
13175 }
13176
13177 protected void ClearStartItemSoundServer()
13178 {
13179 m_SoundSyncPlay = 0;
13180 m_SoundSyncSlotID = InventorySlots.INVALID;
13181 }
13182
13183 protected void ClearStopItemSoundServer()
13184 {
13185 m_SoundSyncStop = 0;
13186 }
13187
13188 void OnApply(PlayerBase player);
13189
13191 {
13192 return 1.0;
13193 };
13194 //returns applicable selection
13195 array<string> GetHeadHidingSelection()
13196 {
13198 }
13199
13201 {
13203 }
13204
13205 WrittenNoteData GetWrittenNoteData() {};
13206
13208 {
13209 SetDynamicPhysicsLifeTime(0.01);
13210 m_ItemBeingDroppedPhys = false;
13211 }
13212
13214 {
13215 array<string> zone_names = new array<string>;
13216 GetDamageZones(zone_names);
13217 for (int i = 0; i < zone_names.Count(); i++)
13218 {
13219 SetHealthMax(zone_names.Get(i),"Health");
13220 }
13221 SetHealthMax("","Health");
13222 }
13223
13225 void SetZoneDamageCEInit()
13226 {
13227 float global_health = GetHealth01("","Health");
13228 array<string> zones = new array<string>;
13229 GetDamageZones(zones);
13230 //set damage of all zones to match global health level
13231 for (int i = 0; i < zones.Count(); i++)
13232 {
13233 SetHealth01(zones.Get(i),"Health",global_health);
13234 }
13235 }
13236
13238 bool IsCoverFaceForShave(string slot_name)
13239 {
13240 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13241 }
13242
13243 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13244 {
13245 if (!hasRootAsPlayer)
13246 {
13247 if (refParentIB)
13248 {
13249 // parent is wet
13250 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13251 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13252 // parent has liquid inside
13253 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13254 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13255 // drying
13256 else if (m_VarWet > m_VarWetMin)
13257 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13258 }
13259 else
13260 {
13261 // drying on ground or inside non-itembase (car, ...)
13262 if (m_VarWet > m_VarWetMin)
13263 AddWet(-1 * delta * GetDryingIncrement("ground"));
13264 }
13265 }
13266 }
13267
13268 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13269 {
13271 {
13272 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13273 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13274 {
13275 float heatPermCoef = 1.0;
13276 EntityAI ent = this;
13277 while (ent)
13278 {
13279 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13280 ent = ent.GetHierarchyParent();
13281 }
13282
13283 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13284 }
13285 }
13286 }
13287
13288 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13289 {
13290 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13291 EntityAI parent = GetHierarchyParent();
13292 if (!parent)
13293 {
13294 hasParent = false;
13295 hasRootAsPlayer = false;
13296 }
13297 else
13298 {
13299 hasParent = true;
13300 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13301 refParentIB = ItemBase.Cast(parent);
13302 }
13303 }
13304
13305 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13306 {
13307 // this is stub, implemented on Edible_Base
13308 }
13309
13310 bool CanDecay()
13311 {
13312 // return true used on selected food clases so they can decay
13313 return false;
13314 }
13315
13316 protected bool CanProcessDecay()
13317 {
13318 // this is stub, implemented on Edible_Base class
13319 // used to determine whether it is still necessary for the food to decay
13320 return false;
13321 }
13322
13323 protected bool CanHaveWetness()
13324 {
13325 // return true used on selected items that have a wetness effect
13326 return false;
13327 }
13328
13330 bool CanBeConsumed(ConsumeConditionData data = null)
13331 {
13332 return !GetIsFrozen() && IsOpen();
13333 }
13334
13335 override void ProcessVariables()
13336 {
13337 bool hasParent = false, hasRootAsPlayer = false;
13338 ItemBase refParentIB;
13339
13340 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13341 bool foodDecay = g_Game.IsFoodDecayEnabled();
13342
13343 if (wwtu || foodDecay)
13344 {
13345 bool processWetness = wwtu && CanHaveWetness();
13346 bool processTemperature = wwtu && CanHaveTemperature();
13347 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13348
13349 if (processWetness || processTemperature || processDecay)
13350 {
13351 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13352
13353 if (processWetness)
13354 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13355
13356 if (processTemperature)
13357 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13358
13359 if (processDecay)
13360 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13361 }
13362 }
13363 }
13364
13367 {
13368 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13369 }
13370
13371 override float GetTemperatureFreezeThreshold()
13372 {
13374 return Liquid.GetFreezeThreshold(GetLiquidType());
13375
13376 return super.GetTemperatureFreezeThreshold();
13377 }
13378
13379 override float GetTemperatureThawThreshold()
13380 {
13382 return Liquid.GetThawThreshold(GetLiquidType());
13383
13384 return super.GetTemperatureThawThreshold();
13385 }
13386
13387 override float GetItemOverheatThreshold()
13388 {
13390 return Liquid.GetBoilThreshold(GetLiquidType());
13391
13392 return super.GetItemOverheatThreshold();
13393 }
13394
13395 override float GetTemperatureFreezeTime()
13396 {
13397 if (HasQuantity())
13398 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13399
13400 return super.GetTemperatureFreezeTime();
13401 }
13402
13403 override float GetTemperatureThawTime()
13404 {
13405 if (HasQuantity())
13406 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13407
13408 return super.GetTemperatureThawTime();
13409 }
13410
13412 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13414 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13415
13416 bool IsCargoException4x3(EntityAI item)
13417 {
13418 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13419 }
13420
13422 {
13423 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13424 }
13425
13427 void AddLightSourceItem(ItemBase lightsource)
13428 {
13429 m_LightSourceItem = lightsource;
13430 }
13431
13433 {
13434 m_LightSourceItem = null;
13435 }
13436
13438 {
13439 return m_LightSourceItem;
13440 }
13441
13443 array<int> GetValidFinishers()
13444 {
13445 return null;
13446 }
13447
13449 bool GetActionWidgetOverride(out typename name)
13450 {
13451 return false;
13452 }
13453
13454 bool PairWithDevice(notnull ItemBase otherDevice)
13455 {
13456 if (g_Game.IsServer())
13457 {
13458 ItemBase explosive = otherDevice;
13460 if (!trg)
13461 {
13462 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13463 explosive = this;
13464 }
13465
13466 explosive.PairRemote(trg);
13467 trg.SetControlledDevice(explosive);
13468
13469 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13470 trg.SetPersistentPairID(persistentID);
13471 explosive.SetPersistentPairID(persistentID);
13472
13473 return true;
13474 }
13475 return false;
13476 }
13477
13479 float GetBaitEffectivity()
13480 {
13481 float ret = 1.0;
13482 if (HasQuantity())
13483 ret *= GetQuantityNormalized();
13484 ret *= GetHealth01();
13485
13486 return ret;
13487 }
13488
13489 #ifdef DEVELOPER
13490 override void SetDebugItem()
13491 {
13492 super.SetDebugItem();
13493 _itemBase = this;
13494 }
13495
13496 override string GetDebugText()
13497 {
13498 string text = super.GetDebugText();
13499
13500 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13501 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13502
13503 return text;
13504 }
13505 #endif
13506
13507 bool CanBeUsedForSuicide()
13508 {
13509 return true;
13510 }
13511
13513 //DEPRECATED BELOW
13515 // Backwards compatibility
13516 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13517 {
13518 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13519 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13520 }
13521
13522 // replaced by ItemSoundHandler
13523 protected EffectSound m_SoundDeployFinish;
13524 protected EffectSound m_SoundPlace;
13525 protected EffectSound m_DeployLoopSoundEx;
13526 protected EffectSound m_SoundDeploy;
13527 bool m_IsPlaceSound;
13528 bool m_IsDeploySound;
13530
13531 string GetDeployFinishSoundset();
13532 void PlayDeploySound();
13533 void PlayDeployFinishSound();
13534 void PlayPlaceSound();
13535 void PlayDeployLoopSoundEx();
13536 void StopDeployLoopSoundEx();
13537 void SoundSynchRemoteReset();
13538 void SoundSynchRemote();
13539 bool UsesGlobalDeploy(){return false;}
13540 bool CanPlayDeployLoopSound(){return false;}
13542 bool IsPlaceSound(){return m_IsPlaceSound;}
13543 bool IsDeploySound(){return m_IsDeploySound;}
13544 void SetIsPlaceSound(bool is_place_sound);
13545 void SetIsDeploySound(bool is_deploy_sound);
13546
13547 [Obsolete("Use ItemSoundHandler instead")]
13549 void PlayAttachSound(string slot_type)
13550 {
13551 if (!g_Game.IsDedicatedServer())
13552 {
13553 if (ConfigIsExisting("attachSoundSet"))
13554 {
13555 string cfg_path = "";
13556 string soundset = "";
13557 string type_name = GetType();
13558
13559 TStringArray cfg_soundset_array = new TStringArray;
13560 TStringArray cfg_slot_array = new TStringArray;
13561 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13562 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13563
13564 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13565 {
13566 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13567 {
13568 if (cfg_slot_array[i] == slot_type)
13569 {
13570 soundset = cfg_soundset_array[i];
13571 break;
13572 }
13573 }
13574 }
13575
13576 if (soundset != "")
13577 {
13578 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13579 sound.SetAutodestroy(true);
13580 }
13581 }
13582 }
13583 }
13584
13585 void PlayDetachSound(string slot_type) {}
13586}
13587
13588EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13589{
13590 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13591 if (entity)
13592 {
13593 bool is_item = entity.IsInherited(ItemBase);
13594 if (is_item && full_quantity)
13595 {
13596 ItemBase item = ItemBase.Cast(entity);
13597 item.SetQuantity(item.GetQuantityInit());
13598 }
13599 }
13600 else
13601 {
13602 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13603 return NULL;
13604 }
13605 return entity;
13606}
13607
13608void SetupSpawnedItem(ItemBase item, float health, float quantity)
13609{
13610 if (item)
13611 {
13612 if (health > 0)
13613 item.SetHealth("", "", health);
13614
13615 if (item.CanHaveTemperature())
13616 {
13617 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13618 if (item.CanFreeze())
13619 item.SetFrozen(false);
13620 }
13621
13622 if (item.HasEnergyManager())
13623 {
13624 if (quantity >= 0)
13625 {
13626 item.GetCompEM().SetEnergy0To1(quantity);
13627 }
13628 else
13629 {
13630 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13631 }
13632 }
13633 else if (item.IsMagazine())
13634 {
13635 Magazine mag = Magazine.Cast(item);
13636 if (quantity >= 0)
13637 {
13638 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13639 }
13640 else
13641 {
13642 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13643 }
13644
13645 }
13646 else
13647 {
13648 if (quantity >= 0)
13649 {
13650 item.SetQuantityNormalized(quantity, false);
13651 }
13652 else
13653 {
13654 item.SetQuantity(Math.AbsFloat(quantity));
13655 }
13656
13657 }
13658 }
13659}
13660
13661#ifdef DEVELOPER
13662ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13663#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/DayZ/Entities/EntityAI.c:2
bool SetAttachSoundEvent()
void InventoryItemType()
bool SetDetachSoundEvent()
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:34
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
string Debug()
Определения CachedEquipmentStorageBase.c:29
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3942
DayZGame GetDayZGame()
Определения DayZGame.c:3944
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:159
const int MIN
Определения EnConvert.c:28
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:500
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool IsPrepareToDelete()
Определения FireplaceBase.c:643
override bool CanHaveTemperature()
Определения FireplaceBase.c:561
class GP5GasMask extends MaskBase ItemBase
proto GizmoApi GetGizmoApi()
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6453
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5680
bool HidesSelectionBySlot()
Определения ItemBase.c:9413
float m_VarWetMin
Определения ItemBase.c:4937
void SplitItem(PlayerBase player)
Определения ItemBase.c:6908
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9634
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8895
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8330
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5685
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:9038
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6875
override bool IsHeavyBehaviour()
Определения ItemBase.c:9240
override void SetWetMax()
Определения ItemBase.c:8616
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9451
void ClearStartItemSoundServer()
Определения ItemBase.c:9390
float m_VarWet
Определения ItemBase.c:4934
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9481
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:3
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8890
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4997
bool CanBeMovedOverride()
Определения ItemBase.c:7600
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8592
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4983
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:9358
override void ProcessVariables()
Определения ItemBase.c:9548
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:5011
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8423
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8956
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8806
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5271
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:5009
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9584
bool m_IsSoundSynchRemote
Определения ItemBase.c:9742
float m_OverheatingShots
Определения ItemBase.c:5004
void StopItemSoundServer(int id)
Определения ItemBase.c:9378
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5700
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5424
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9608
ref array< int > m_CompatibleLocks
Определения ItemBase.c:5021
bool CanBeCooked()
Определения ItemBase.c:7556
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5767
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:5035
bool m_RecipesInitialized
Определения ItemBase.c:4919
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6546
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9592
override void OnEnergyConsumed()
Определения ItemBase.c:8536
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8462
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8656
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8418
ref TIntArray m_InteractActions
Определения ItemBase.c:4985
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7620
float m_VarQuantity
Определения ItemBase.c:4925
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9753
override float GetWetMax()
Определения ItemBase.c:8626
bool CanBeUsedForSuicide()
Определения ItemBase.c:9720
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7193
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5905
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7774
void DoAmmoExplosion()
Определения ItemBase.c:6388
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4996
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6732
int GetItemSize()
Определения ItemBase.c:7585
bool m_CanBeMovedOverride
Определения ItemBase.c:4962
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6312
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5492
bool CanDecay()
Определения ItemBase.c:9523
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8303
void SetQuantityMax()
Определения ItemBase.c:8308
override float GetQuantity()
Определения ItemBase.c:8398
int m_ColorComponentR
Определения ItemBase.c:4974
int m_ShotsToStartOverheating
Определения ItemBase.c:5006
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8641
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5499
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9139
void OnOverheatingDecay()
Определения ItemBase.c:5462
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8574
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4940
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5600
bool UsesGlobalDeploy()
Определения ItemBase.c:9752
int m_ItemBehaviour
Определения ItemBase.c:4955
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9111
float m_HeatIsolation
Определения ItemBase.c:4950
float m_VarWetInit
Определения ItemBase.c:4936
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5945
void SetCEBasedQuantity()
Определения ItemBase.c:5713
bool m_CanPlayImpactSound
Определения ItemBase.c:4946
override string GetAttachmentSoundType()
Определения ItemBase.c:9314
float GetOverheatingCoef()
Определения ItemBase.c:5519
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9408
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9762
override bool IsStoreLoad()
Определения ItemBase.c:8668
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7169
bool IsLightSource()
Определения ItemBase.c:5841
bool m_HasQuantityBar
Определения ItemBase.c:4968
void SetResultOfSplit(bool value)
Определения ItemBase.c:7164
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6796
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6965
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5527
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8583
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9219
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8678
int m_LockType
Определения ItemBase.c:5022
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:5027
bool m_CanBeDigged
Определения ItemBase.c:4969
float m_ItemAttachOffset
Определения ItemBase.c:4952
float GetItemModelLength()
Определения ItemBase.c:8685
bool m_ThrowItemOnDrop
Определения ItemBase.c:4960
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7919
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8971
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8569
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7198
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9579
bool CanHaveWetness()
Определения ItemBase.c:9536
int m_CleannessMin
Определения ItemBase.c:4942
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8904
string IDToName(int id)
Определения ItemBase.c:7767
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9543
float GetHeatIsolationInit()
Определения ItemBase.c:8564
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7607
override bool HasQuantity()
Определения ItemBase.c:8393
float m_VarWetPrev
Определения ItemBase.c:4935
int m_SoundSyncStop
Определения ItemBase.c:5029
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9629
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4984
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5609
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5294
int m_VarLiquidType
Определения ItemBase.c:4954
int m_QuickBarBonus
Определения ItemBase.c:4956
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9302
override float GetWetInit()
Определения ItemBase.c:8636
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4948
int m_SoundSyncPlay
Определения ItemBase.c:5028
int m_MaxOverheatingValue
Определения ItemBase.c:5007
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4931
bool m_IsTakeable
Определения ItemBase.c:4959
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6503
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4999
string GetLockSoundSet()
Определения ItemBase.c:8734
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8765
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9656
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6971
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4911
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9329
override int GetQuantityMin()
Определения ItemBase.c:8382
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6711
override int GetQuickBarBonus()
Определения ItemBase.c:5179
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
float m_OverheatingDecayInterval
Определения ItemBase.c:5008
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6523
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9501
bool CanProcessDecay()
Определения ItemBase.c:9529
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5690
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9645
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7571
bool can_this_be_combined
Определения ItemBase.c:4964
EffectSound m_SoundDeploy
Определения ItemBase.c:9739
int m_SoundSyncSlotID
Определения ItemBase.c:5030
int m_Count
Определения ItemBase.c:4930
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9692
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9276
override bool IsSplitable()
Определения ItemBase.c:6490
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6473
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7883
void ConvertEnergyToQuantity()
Определения ItemBase.c:8551
override void RemoveAllAgents()
Определения ItemBase.c:8885
override void SetQuantityToMinimum()
Определения ItemBase.c:8314
bool m_WantPlayImpactSound
Определения ItemBase.c:4945
override float GetTemperatureThawTime()
Определения ItemBase.c:9616
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4998
int m_ColorComponentG
Определения ItemBase.c:4975
float m_StoreLoadedQuantity
Определения ItemBase.c:4932
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7638
int m_ColorComponentA
Определения ItemBase.c:4977
int m_VarQuantityInit
Определения ItemBase.c:4927
float GetFilterDamageRatio()
Определения ItemBase.c:5594
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8778
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6942
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8321
bool m_HideSelectionsBySlot
Определения ItemBase.c:5012
bool IsOverheatingEffectActive()
Определения ItemBase.c:5457
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5874
int GetLiquidContainerMask()
Определения ItemBase.c:5811
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7078
ref Timer m_CheckOverheating
Определения ItemBase.c:5005
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5505
float GetEnergy()
Определения ItemBase.c:8525
bool CanBeDigged()
Определения ItemBase.c:5890
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9662
bool IsNVG()
Определения ItemBase.c:5822
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8485
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9438
bool m_IsDeploySound
Определения ItemBase.c:9741
bool CanEat()
Определения ItemBase.c:7531
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9179
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9250
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9640
bool IsLiquidContainer()
Определения ItemBase.c:5806
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7551
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8409
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8963
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8363
int m_CleannessInit
Определения ItemBase.c:4941
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5589
override int GetAgents()
Определения ItemBase.c:8910
int m_VarQuantityMax
Определения ItemBase.c:4929
override bool IsHologram()
Определения ItemBase.c:5885
float GetItemAttachOffset()
Определения ItemBase.c:8694
bool IsPlaceSound()
Определения ItemBase.c:9755
static int GetDebugActionsMask()
Определения ItemBase.c:5675
override int GetLiquidType()
Определения ItemBase.c:8794
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9518
override bool IsItemBase()
Определения ItemBase.c:7684
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9260
void ExplodeAmmo()
Определения ItemBase.c:6375
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7154
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8984
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9159
override void OnEnergyAdded()
Определения ItemBase.c:8543
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5834
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9738
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7824
void StopItemDynamicPhysics()
Определения ItemBase.c:9420
bool HasFoodStage()
Определения ItemBase.c:7544
override void SetStoreLoad(bool value)
Определения ItemBase.c:8663
float GetOverheatingValue()
Определения ItemBase.c:5419
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8863
override void AddWet(float value)
Определения ItemBase.c:8611
bool IsLiquidPresent()
Определения ItemBase.c:5801
bool IsFullQuantity()
Определения ItemBase.c:8403
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6084
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6847
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6823
int m_CleannessMax
Определения ItemBase.c:4943
float m_VarStackMax
Определения ItemBase.c:4931
ref Timer m_PhysDropTimer
Определения ItemBase.c:5018
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7656
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8673
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4972
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5440
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5755
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7578
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8799
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5486
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8721
bool m_IsOverheatingEffectActive
Определения ItemBase.c:5003
int m_LiquidContainerMask
Определения ItemBase.c:4953
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9456
override int GetCleanness()
Определения ItemBase.c:8716
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9667
bool IsDeploySound()
Определения ItemBase.c:9756
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5695
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9199
int m_VarQuantityMin
Определения ItemBase.c:4928
void PerformDamageSystemReinit()
Определения ItemBase.c:9426
override void ClearInventory()
Определения ItemBase.c:8504
static int m_LastRegisteredWeaponID
Определения ItemBase.c:5000
ItemBase GetLightSourceItem()
Определения ItemBase.c:9650
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7674
override float GetItemOverheatThreshold()
Определения ItemBase.c:9600
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4965
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7788
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6762
float m_ItemModelLength
Определения ItemBase.c:4951
bool m_IsHologram
Определения ItemBase.c:4958
static int m_DebugActionsMask
Определения ItemBase.c:4918
void KillAllOverheatingParticles()
Определения ItemBase.c:5555
bool CanBeCookedOnStick()
Определения ItemBase.c:7561
override int GetQuantityMax()
Определения ItemBase.c:8349
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7232
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8759
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8876
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4961
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:9066
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9798
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4912
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9729
override bool IsBeingPlaced()
Определения ItemBase.c:5869
int GetQuantityInit()
Определения ItemBase.c:8387
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7174
bool IsResultOfSplit()
Определения ItemBase.c:7159
bool m_FixDamageSystemInit
Определения ItemBase.c:4963
float m_ImpactSpeed
Определения ItemBase.c:4947
bool m_IsStoreLoad
Определения ItemBase.c:4966
int GetLiquidTypeInit()
Определения ItemBase.c:8789
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4981
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5742
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6633
int m_AttachedAgents
Определения ItemBase.c:4989
string m_LockSoundSet
Определения ItemBase.c:5024
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5363
float m_VarQuantityPrev
Определения ItemBase.c:4926
bool IsSoundSynchRemote()
Определения ItemBase.c:9754
bool m_CanShowQuantity
Определения ItemBase.c:4967
override void OnRightClick()
Определения ItemBase.c:7014
int m_ColorComponentB
Определения ItemBase.c:4976
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4914
bool IsActionTargetVisible()
Определения ItemBase.c:9296
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6119
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6412
bool m_IsBeingPlaced
Определения ItemBase.c:4957
int NameToID(string name)
Определения ItemBase.c:7761
void ~ItemBase()
Определения ItemBase.c:5640
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8651
void ClearStopItemSoundServer()
Определения ItemBase.c:9396
override string ChangeIntoOnDetach()
Определения ItemBase.c:6336
float m_VarWetMax
Определения ItemBase.c:4938
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6757
int GetLockType()
Определения ItemBase.c:8729
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9736
override float GetWet()
Определения ItemBase.c:8621
EffectSound m_SoundPlace
Определения ItemBase.c:9737
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8335
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8703
bool m_IsPlaceSound
Определения ItemBase.c:9740
override float GetWetMin()
Определения ItemBase.c:8631
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:5032
override bool KindOf(string tag)
Определения ItemBase.c:7690
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:336
string GetDebugText()
Определения ModifierBase.c:71
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
int GetID()
Определения ActionBase.c:1335
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:974
GetInputType()
Определения ActionBase.c:221
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1325
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:550
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1320
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/DayZ/Entities/Man.c:48
proto native EntityAI GetAttachmentFromIndex(int index)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto void SelectObject(Object object)
proto void SelectPhysics(Physics physics)
Определения ItemBase.c:21
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:507
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
override bool CanDisplayCargo()
Определения TentBase.c:91
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:7
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:934
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:397
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:409
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения ItemBase.c:14
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:40
proto native float GetDamage(string zoneName, string healthType)
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/DayZ/tools/Debug.c:916
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:113
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:515
const int DEF_CHEMICAL
Определения 3_Game/DayZ/constants.c:516
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:712
array< int > TIntArray
Определения EnScript.c:714
void Obsolete(string msg="")
Определения EnScript.c:371
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:811
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/DayZ/constants.c:635
const int VARIABLE_CLEANNESS
Определения 3_Game/DayZ/constants.c:638
const int VARIABLE_COLOR
Определения 3_Game/DayZ/constants.c:637
const int VARIABLE_TEMPERATURE
Определения 3_Game/DayZ/constants.c:633
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:631
const int VARIABLE_WET
Определения 3_Game/DayZ/constants.c:634
const int LIQUID_NONE
Определения 3_Game/DayZ/constants.c:532
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/DayZ/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/DayZ/constants.c:456
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native int GetColor()

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