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

◆ SetCleanness()

override void SpawnItemOnLocation::SetCleanness ( int value,
bool allow_client = false )
protected

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

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

Используется в InventoryItem::DeSerializeNumericalVars(), InventoryItem::EEHealthLevelChanged(), ItemBase::OnCombine(), SewingKit::OnCombine() и InventoryItem::ReadVarsFromCTX().