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

◆ GetWetInit()

override float SpawnItemOnLocation::GetWetInit ( )
protected

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

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