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

◆ SetQuantity()

override bool SpawnItemOnLocation::SetQuantity ( float value,
bool destroy_config = true,
bool destroy_forced = false,
bool allow_client = false,
bool clamp_to_stack_max = true )
protected

Set item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity reaches varQuantityMin or lower and the item config contains the varQuantityDestroyOnMin = true entry, the item gets destroyed. destroy_forced = true means item gets destroyed when quantity reaches varQuantityMin or lower regardless of config setting, returns true if the item gets deleted.

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

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

Используется в CalcAndSetQuantity(), Capture(), MaskBase::EEHealthLevelChanged() и Release().