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

◆ GetSingleInventoryItemWeight()

float SpawnItemOnLocation::GetSingleInventoryItemWeight ( )
protected

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

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