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

◆ CanEat()

bool SpawnItemOnLocation::CanEat ( )
protected

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

7536{
7537 override bool CanPutAsAttachment(EntityAI parent)
7538 {
7539 return true;
7540 }
7541};
7542
7544{
7545
7546};
7547
7548//const bool QUANTITY_DEBUG_REMOVE_ME = false;
7549
7550class ItemBase extends InventoryItem
7551{
7555
7557
7558 static int m_DebugActionsMask;
7560 // ============================================
7561 // Variable Manipulation System
7562 // ============================================
7563 // Quantity
7564
7565 float m_VarQuantity;
7566 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
7568 int m_VarQuantityMin;
7569 int m_VarQuantityMax;
7570 int m_Count;
7571 float m_VarStackMax;
7572 float m_StoreLoadedQuantity = float.LOWEST;
7573 // Wet
7574 float m_VarWet;
7575 float m_VarWetPrev;//for client to know wetness changed during synchronization
7576 float m_VarWetInit;
7577 float m_VarWetMin;
7578 float m_VarWetMax;
7579 // Cleanness
7580 int m_Cleanness;
7581 int m_CleannessInit;
7582 int m_CleannessMin;
7583 int m_CleannessMax;
7584 // impact sounds
7586 bool m_CanPlayImpactSound = true;
7587 float m_ImpactSpeed;
7589 //
7590 float m_HeatIsolation;
7591 float m_ItemModelLength;
7592 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
7594 int m_VarLiquidType;
7595 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
7596 int m_QuickBarBonus;
7597 bool m_IsBeingPlaced;
7598 bool m_IsHologram;
7599 bool m_IsTakeable;
7600 bool m_ThrowItemOnDrop;
7603 bool m_FixDamageSystemInit = false; //can be changed on storage version check
7604 bool can_this_be_combined; //Check if item can be combined
7605 bool m_CanThisBeSplit; //Check if item can be split
7606 bool m_IsStoreLoad = false;
7607 bool m_CanShowQuantity;
7608 bool m_HasQuantityBar;
7609 protected bool m_CanBeDigged;
7610 protected bool m_IsResultOfSplit
7611
7612 string m_SoundAttType;
7613 // items color variables
7618 //-------------------------------------------------------
7619
7620 // light source managing
7622
7626
7627 //==============================================
7628 // agent system
7629 private int m_AttachedAgents;
7630
7632 void TransferModifiers(PlayerBase reciever);
7633
7634
7635 // Weapons & suppressors particle effects
7639 ref static map<string, int> m_WeaponTypeToID;
7640 static int m_LastRegisteredWeaponID = 0;
7641
7642 // Overheating effects
7644 float m_OverheatingShots;
7645 ref Timer m_CheckOverheating;
7646 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
7647 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
7648 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
7649 ref array <ref OverheatingParticle> m_OverheatingParticles;
7650
7652 protected bool m_HideSelectionsBySlot;
7653
7654 // Admin Log
7655 PluginAdminLog m_AdminLog;
7656
7657 // misc
7658 ref Timer m_PhysDropTimer;
7659
7660 // Attachment Locking variables
7661 ref array<int> m_CompatibleLocks;
7662 protected int m_LockType;
7663 protected ref EffectSound m_LockingSound;
7664 protected string m_LockSoundSet;
7665
7666 // ItemSoundHandler variables
7667 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
7668 protected int m_SoundSyncPlay; // id for sound to play
7669 protected int m_SoundSyncStop; // id for sound to stop
7670 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
7671
7673
7674 //temperature
7675 private float m_TemperaturePerQuantityWeight;
7676
7677 // -------------------------------------------------------------------------
7678 void ItemBase()
7679 {
7680 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
7684
7685 if (!g_Game.IsDedicatedServer())
7686 {
7687 if (HasMuzzle())
7688 {
7690
7692 {
7694 }
7695 }
7696
7698 m_ActionsInitialize = false;
7699 }
7700
7701 m_OldLocation = null;
7702
7703 if (g_Game.IsServer())
7704 {
7705 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
7706 }
7707
7708 if (ConfigIsExisting("headSelectionsToHide"))
7709 {
7711 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
7712 }
7713
7714 m_HideSelectionsBySlot = false;
7715 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
7716 {
7717 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
7718 }
7719
7720 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
7721
7722 m_IsResultOfSplit = false;
7723
7725 }
7726
7727 override void InitItemVariables()
7728 {
7729 super.InitItemVariables();
7730
7731 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
7732 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
7733 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
7734 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
7735 m_VarStackMax = ConfigGetFloat("varStackMax");
7736 m_Count = ConfigGetInt("count");
7737
7738 m_CanShowQuantity = ConfigGetBool("quantityShow");
7739 m_HasQuantityBar = ConfigGetBool("quantityBar");
7740
7741 m_CleannessInit = ConfigGetInt("varCleannessInit");
7743 m_CleannessMin = ConfigGetInt("varCleannessMin");
7744 m_CleannessMax = ConfigGetInt("varCleannessMax");
7745
7746 m_WantPlayImpactSound = false;
7747 m_ImpactSpeed = 0.0;
7748
7749 m_VarWetInit = ConfigGetFloat("varWetInit");
7751 m_VarWetMin = ConfigGetFloat("varWetMin");
7752 m_VarWetMax = ConfigGetFloat("varWetMax");
7753
7754 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
7755 if (IsLiquidContainer() && GetQuantity() != 0)
7757 m_IsBeingPlaced = false;
7758 m_IsHologram = false;
7759 m_IsTakeable = true;
7760 m_CanBeMovedOverride = false;
7764 m_CanBeDigged = ConfigGetBool("canBeDigged");
7765
7766 m_CompatibleLocks = new array<int>();
7767 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
7768 m_LockType = ConfigGetInt("lockType");
7769
7770 //Define if item can be split and set ability to be combined accordingly
7771 m_CanThisBeSplit = false;
7772 can_this_be_combined = false;
7773 if (ConfigIsExisting("canBeSplit"))
7774 {
7775 can_this_be_combined = ConfigGetBool("canBeSplit");
7777 }
7778
7779 m_ItemBehaviour = -1;
7780 if (ConfigIsExisting("itemBehaviour"))
7781 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
7782
7783 //RegisterNetSyncVariableInt("m_VariablesMask");
7784 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7785 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
7786 RegisterNetSyncVariableInt("m_VarLiquidType");
7787 RegisterNetSyncVariableInt("m_Cleanness",0,1);
7788
7789 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
7790 RegisterNetSyncVariableFloat("m_ImpactSpeed");
7791 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
7792
7793 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
7794 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
7795 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
7796 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
7797
7798 RegisterNetSyncVariableBool("m_IsBeingPlaced");
7799 RegisterNetSyncVariableBool("m_IsTakeable");
7800 RegisterNetSyncVariableBool("m_IsHologram");
7801
7804 {
7805 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
7806 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
7807 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
7808 }
7809
7810 m_LockSoundSet = ConfigGetString("lockSoundSet");
7811
7813 if (ConfigIsExisting("temperaturePerQuantityWeight"))
7814 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
7815
7816 m_SoundSyncSlotID = -1;
7817 }
7818
7819 override int GetQuickBarBonus()
7820 {
7821 return m_QuickBarBonus;
7822 }
7823
7824 void InitializeActions()
7825 {
7827 if (!m_InputActionMap)
7828 {
7830 m_InputActionMap = iam;
7831 SetActions();
7833 }
7834 }
7835
7836 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
7837 {
7839 {
7840 m_ActionsInitialize = true;
7842 }
7843
7844 actions = m_InputActionMap.Get(action_input_type);
7845 }
7846
7847 void SetActions()
7848 {
7849 AddAction(ActionTakeItem);
7850 AddAction(ActionTakeItemToHands);
7851 AddAction(ActionWorldCraft);
7853 AddAction(ActionAttachWithSwitch);
7854 }
7855
7856 void SetActionAnimOverrides(); // Override action animation for specific item
7857
7858 void AddAction(typename actionName)
7859 {
7860 ActionBase action = ActionManagerBase.GetAction(actionName);
7861
7862 if (!action)
7863 {
7864 Debug.LogError("Action " + actionName + " dosn't exist!");
7865 return;
7866 }
7867
7868 typename ai = action.GetInputType();
7869 if (!ai)
7870 {
7871 m_ActionsInitialize = false;
7872 return;
7873 }
7874
7875 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7876 if (!action_array)
7877 {
7878 action_array = new array<ActionBase_Basic>;
7879 m_InputActionMap.Insert(ai, action_array);
7880 }
7881 if (LogManager.IsActionLogEnable())
7882 {
7883 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
7884 }
7885
7886 if (action_array.Find(action) != -1)
7887 {
7888 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
7889 }
7890 else
7891 {
7892 action_array.Insert(action);
7893 }
7894 }
7895
7896 void RemoveAction(typename actionName)
7897 {
7898 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7899 ActionBase action = player.GetActionManager().GetAction(actionName);
7900 typename ai = action.GetInputType();
7901 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7902
7903 if (action_array)
7904 {
7905 action_array.RemoveItem(action);
7906 }
7907 }
7908
7909 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
7910 // Set -1 for params which should stay in default state
7911 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
7912 {
7913 ActionOverrideData overrideData = new ActionOverrideData();
7914 overrideData.m_CommandUID = commandUID;
7915 overrideData.m_CommandUIDProne = commandUIDProne;
7916 overrideData.m_StanceMask = stanceMask;
7917
7918 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
7919 if (!actionMap) // create new map of action > overidables map
7920 {
7921 actionMap = new TActionAnimOverrideMap();
7922 m_ItemActionOverrides.Insert(action, actionMap);
7923 }
7924
7925 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
7926
7927 }
7928
7929 void OnItemInHandsPlayerSwimStart(PlayerBase player);
7930
7931 ScriptedLightBase GetLight();
7932
7933 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7934 void LoadParticleConfigOnFire(int id)
7935 {
7936 if (!m_OnFireEffect)
7938
7941
7942 string config_to_search = "CfgVehicles";
7943 string muzzle_owner_config;
7944
7945 if (!m_OnFireEffect.Contains(id))
7946 {
7947 if (IsInherited(Weapon))
7948 config_to_search = "CfgWeapons";
7949
7950 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7951
7952 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
7953
7954 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
7955
7956 if (config_OnFire_subclass_count > 0)
7957 {
7958 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
7959
7960 for (int i = 0; i < config_OnFire_subclass_count; i++)
7961 {
7962 string particle_class = "";
7963 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
7964 string config_OnFire_entry = config_OnFire_class + particle_class;
7965 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
7966 WPOF_array.Insert(WPOF);
7967 }
7968
7969
7970 m_OnFireEffect.Insert(id, WPOF_array);
7971 }
7972 }
7973
7974 if (!m_OnBulletCasingEjectEffect.Contains(id))
7975 {
7976 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
7977 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7978
7979 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
7980
7981 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
7982
7983 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
7984 {
7985 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
7986
7987 for (i = 0; i < config_OnBulletCasingEject_count; i++)
7988 {
7989 string particle_class2 = "";
7990 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
7991 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
7992 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
7993 WPOBE_array.Insert(WPOBE);
7994 }
7995
7996
7997 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
7998 }
7999 }
8000 }
8001
8002 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8004 {
8007
8008 if (!m_OnOverheatingEffect.Contains(id))
8009 {
8010 string config_to_search = "CfgVehicles";
8011
8012 if (IsInherited(Weapon))
8013 config_to_search = "CfgWeapons";
8014
8015 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
8016 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
8017
8018 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
8019 {
8020
8021 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
8022
8024 {
8025 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
8026 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
8027 Error(error);
8028 return;
8029 }
8030
8031 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
8032 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
8033
8034
8035
8036 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
8037 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
8038
8039 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
8040 {
8041 string particle_class = "";
8042 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
8043 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
8044 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
8045
8046 if (entry_type == CT_CLASS)
8047 {
8048 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
8049 WPOOH_array.Insert(WPOF);
8050 }
8051 }
8052
8053
8054 m_OnOverheatingEffect.Insert(id, WPOOH_array);
8055 }
8056 }
8057 }
8058
8059 float GetOverheatingValue()
8060 {
8061 return m_OverheatingShots;
8062 }
8063
8064 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8065 {
8066 if (m_MaxOverheatingValue > 0)
8067 {
8069
8070 if (!m_CheckOverheating)
8072
8074 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8075
8076 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8077 }
8078 }
8079
8080 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8081 {
8083 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8084
8086 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8087
8089 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8090
8092 {
8094 }
8095 }
8096
8098 {
8100 }
8101
8102 void OnOverheatingDecay()
8103 {
8104 if (m_MaxOverheatingValue > 0)
8105 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8106 else
8108
8109 if (m_OverheatingShots <= 0)
8110 {
8113 }
8114 else
8115 {
8116 if (!m_CheckOverheating)
8118
8120 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8121 }
8122
8123 CheckOverheating(this, "", this);
8124 }
8125
8126 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8127 {
8129 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8130 }
8131
8132 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8133 {
8135 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8137 }
8138
8139 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8140 {
8142 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8143 }
8144
8145 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
8146 {
8148 m_OverheatingParticles = new array<ref OverheatingParticle>;
8149
8150 OverheatingParticle OP = new OverheatingParticle();
8151 OP.RegisterParticle(p);
8152 OP.SetOverheatingLimitMin(min_heat_coef);
8153 OP.SetOverheatingLimitMax(max_heat_coef);
8154 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
8155
8156 m_OverheatingParticles.Insert(OP);
8157 }
8158
8159 float GetOverheatingCoef()
8160 {
8161 if (m_MaxOverheatingValue > 0)
8163
8164 return -1;
8165 }
8166
8168 {
8170 {
8171 float overheat_coef = GetOverheatingCoef();
8172 int count = m_OverheatingParticles.Count();
8173
8174 for (int i = count; i > 0; --i)
8175 {
8176 int id = i - 1;
8177 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8178 Particle p = OP.GetParticle();
8179
8180 float overheat_min = OP.GetOverheatingLimitMin();
8181 float overheat_max = OP.GetOverheatingLimitMax();
8182
8183 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
8184 {
8185 if (p)
8186 {
8187 p.Stop();
8188 OP.RegisterParticle(null);
8189 }
8190 }
8191 }
8192 }
8193 }
8194
8196 {
8198 {
8199 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
8200 {
8201 int id = i - 1;
8202 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8203
8204 if (OP)
8205 {
8206 Particle p = OP.GetParticle();
8207
8208 if (p)
8209 {
8210 p.Stop();
8211 }
8212
8213 delete OP;
8214 }
8215 }
8216
8217 m_OverheatingParticles.Clear();
8219 }
8220 }
8221
8223 float GetInfectionChance(int system = 0, Param param = null)
8224 {
8225 return 0.0;
8226 }
8227
8228
8229 float GetDisinfectQuantity(int system = 0, Param param1 = null)
8230 {
8231 return 250;//default value
8232 }
8233
8234 float GetFilterDamageRatio()
8235 {
8236 return 0;
8237 }
8238
8240 bool HasMuzzle()
8241 {
8242 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
8243 return true;
8244
8245 return false;
8246 }
8247
8249 int GetMuzzleID()
8250 {
8251 if (!m_WeaponTypeToID)
8252 m_WeaponTypeToID = new map<string, int>;
8253
8254 if (m_WeaponTypeToID.Contains(GetType()))
8255 {
8256 return m_WeaponTypeToID.Get(GetType());
8257 }
8258 else
8259 {
8260 // Register new weapon ID
8262 }
8263
8265 }
8266
8273 {
8274 return -1;
8275 }
8276
8277
8278
8279 // -------------------------------------------------------------------------
8280 void ~ItemBase()
8281 {
8282 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
8283 {
8284 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8285 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8286
8287 if (r_index >= 0)
8288 {
8289 InventoryLocation r_il = new InventoryLocation;
8290 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8291
8292 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8293 int r_type = r_il.GetType();
8294 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8295 {
8296 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8297 }
8298 else if (r_type == InventoryLocationType.ATTACHMENT)
8299 {
8300 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8301 }
8302
8303 }
8304
8305 player.GetHumanInventory().ClearUserReservedLocation(this);
8306 }
8307
8308 if (m_LockingSound)
8309 SEffectManager.DestroyEffect(m_LockingSound);
8310 }
8311
8312
8313
8314 // -------------------------------------------------------------------------
8315 static int GetDebugActionsMask()
8316 {
8317 return ItemBase.m_DebugActionsMask;
8318 }
8319
8320 static bool HasDebugActionsMask(int mask)
8321 {
8322 return ItemBase.m_DebugActionsMask & mask;
8323 }
8324
8325 static void SetDebugActionsMask(int mask)
8326 {
8327 ItemBase.m_DebugActionsMask = mask;
8328 }
8329
8330 static void AddDebugActionsMask(int mask)
8331 {
8332 ItemBase.m_DebugActionsMask |= mask;
8333 }
8334
8335 static void RemoveDebugActionsMask(int mask)
8336 {
8337 ItemBase.m_DebugActionsMask &= ~mask;
8338 }
8339
8340 static void ToggleDebugActionsMask(int mask)
8341 {
8342 if (HasDebugActionsMask(mask))
8343 {
8345 }
8346 else
8347 {
8348 AddDebugActionsMask(mask);
8349 }
8350 }
8351
8352 // -------------------------------------------------------------------------
8353 void SetCEBasedQuantity()
8354 {
8355 if (GetEconomyProfile())
8356 {
8357 float q_max = GetEconomyProfile().GetQuantityMax();
8358 if (q_max > 0)
8359 {
8360 float q_min = GetEconomyProfile().GetQuantityMin();
8361 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
8362
8363 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
8364 {
8365 ComponentEnergyManager comp = GetCompEM();
8366 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
8367 {
8368 comp.SetEnergy0To1(quantity_randomized);
8369 }
8370 }
8371 else if (HasQuantity())
8372 {
8373 SetQuantityNormalized(quantity_randomized, false);
8374 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
8375 }
8376
8377 }
8378 }
8379 }
8380
8382 void LockToParent()
8383 {
8384 EntityAI parent = GetHierarchyParent();
8385
8386 if (parent)
8387 {
8388 InventoryLocation inventory_location_to_lock = new InventoryLocation;
8389 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
8390 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
8391 }
8392 }
8393
8395 void UnlockFromParent()
8396 {
8397 EntityAI parent = GetHierarchyParent();
8398
8399 if (parent)
8400 {
8401 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
8402 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
8403 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
8404 }
8405 }
8406
8407 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
8408 {
8409 /*
8410 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
8411 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
8412 */
8413 ItemBase item2 = ItemBase.Cast(entity2);
8414
8415 if (g_Game.IsClient())
8416 {
8417 if (ScriptInputUserData.CanStoreInputUserData())
8418 {
8419 ScriptInputUserData ctx = new ScriptInputUserData;
8421 ctx.Write(-1);
8422 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8423 ctx.Write(i1);
8424 ctx.Write(item2);
8425 ctx.Write(use_stack_max);
8426 ctx.Write(-1);
8427 ctx.Send();
8428
8429 if (IsCombineAll(item2, use_stack_max))
8430 {
8431 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
8432 }
8433 }
8434 }
8435 else if (!g_Game.IsMultiplayer())
8436 {
8437 CombineItems(item2, use_stack_max);
8438 }
8439 }
8440
8441 bool IsLiquidPresent()
8442 {
8443 return (GetLiquidType() != 0 && HasQuantity());
8444 }
8445
8446 bool IsLiquidContainer()
8447 {
8448 return m_LiquidContainerMask != 0;
8449 }
8450
8452 {
8453 return m_LiquidContainerMask;
8454 }
8455
8456 bool IsBloodContainer()
8457 {
8458 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
8459 return false;
8460 }
8461
8462 bool IsNVG()
8463 {
8464 return false;
8465 }
8466
8469 bool IsExplosive()
8470 {
8471 return false;
8472 }
8473
8475 {
8476 return "";
8477 }
8478
8480
8481 bool IsLightSource()
8482 {
8483 return false;
8484 }
8485
8487 {
8488 return true;
8489 }
8490
8491 //--- ACTION CONDITIONS
8492 //direction
8493 bool IsFacingPlayer(PlayerBase player, string selection)
8494 {
8495 return true;
8496 }
8497
8498 bool IsPlayerInside(PlayerBase player, string selection)
8499 {
8500 return true;
8501 }
8502
8503 override bool CanObstruct()
8504 {
8505 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8506 return !player || !IsPlayerInside(player, "");
8507 }
8508
8509 override bool IsBeingPlaced()
8510 {
8511 return m_IsBeingPlaced;
8512 }
8513
8514 void SetIsBeingPlaced(bool is_being_placed)
8515 {
8516 m_IsBeingPlaced = is_being_placed;
8517 if (!is_being_placed)
8519 SetSynchDirty();
8520 }
8521
8522 //server-side
8523 void OnEndPlacement() {}
8524
8525 override bool IsHologram()
8526 {
8527 return m_IsHologram;
8528 }
8529
8530 bool CanBeDigged()
8531 {
8532 return m_CanBeDigged;
8533 }
8534
8536 {
8537 return 1;
8538 }
8539
8540 bool CanMakeGardenplot()
8541 {
8542 return false;
8543 }
8544
8545 void SetIsHologram(bool is_hologram)
8546 {
8547 m_IsHologram = is_hologram;
8548 SetSynchDirty();
8549 }
8550 /*
8551 protected float GetNutritionalEnergy()
8552 {
8553 Edible_Base edible = Edible_Base.Cast(this);
8554 return edible.GetFoodEnergy();
8555 }
8556
8557 protected float GetNutritionalWaterContent()
8558 {
8559 Edible_Base edible = Edible_Base.Cast(this);
8560 return edible.GetFoodWater();
8561 }
8562
8563 protected float GetNutritionalIndex()
8564 {
8565 Edible_Base edible = Edible_Base.Cast(this);
8566 return edible.GetFoodNutritionalIndex();
8567 }
8568
8569 protected float GetNutritionalFullnessIndex()
8570 {
8571 Edible_Base edible = Edible_Base.Cast(this);
8572 return edible.GetFoodTotalVolume();
8573 }
8574
8575 protected float GetNutritionalToxicity()
8576 {
8577 Edible_Base edible = Edible_Base.Cast(this);
8578 return edible.GetFoodToxicity();
8579
8580 }
8581 */
8582
8583
8584 // -------------------------------------------------------------------------
8585 override void OnMovedInsideCargo(EntityAI container)
8586 {
8587 super.OnMovedInsideCargo(container);
8588
8589 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8590 }
8591
8592 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8593 {
8594 super.EEItemLocationChanged(oldLoc, newLoc);
8595
8596 PlayerBase newPlayer = null;
8597 PlayerBase oldPlayer = null;
8598
8599 if (newLoc.GetParent())
8600 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
8601
8602 if (oldLoc.GetParent())
8603 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
8604
8605 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
8606 {
8607 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
8608
8609 if (rIndex >= 0)
8610 {
8611 InventoryLocation rIl = new InventoryLocation;
8612 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
8613
8614 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
8615 int rType = rIl.GetType();
8616 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
8617 {
8618 rIl.GetParent().GetOnReleaseLock().Invoke(this);
8619 }
8620 else if (rType == InventoryLocationType.ATTACHMENT)
8621 {
8622 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
8623 }
8624
8625 }
8626 }
8627
8628 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
8629 {
8630 if (newPlayer)
8631 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
8632
8633 if (newPlayer == oldPlayer)
8634 {
8635 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
8636 {
8637 if (oldLoc.GetType() == InventoryLocationType.CARGO)
8638 {
8639 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
8640 {
8641 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8642 }
8643 }
8644 else
8645 {
8646 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8647 }
8648 }
8649
8650 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
8651 {
8652 int type = oldLoc.GetType();
8653 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
8654 {
8655 oldLoc.GetParent().GetOnSetLock().Invoke(this);
8656 }
8657 else if (type == InventoryLocationType.ATTACHMENT)
8658 {
8659 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
8660 }
8661 }
8662 if (!m_OldLocation)
8663 {
8664 m_OldLocation = new InventoryLocation;
8665 }
8666 m_OldLocation.Copy(oldLoc);
8667 }
8668 else
8669 {
8670 if (m_OldLocation)
8671 {
8672 m_OldLocation.Reset();
8673 }
8674 }
8675
8676 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
8677 }
8678 else
8679 {
8680 if (newPlayer)
8681 {
8682 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
8683 if (resIndex >= 0)
8684 {
8685 InventoryLocation il = new InventoryLocation;
8686 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
8687 ItemBase it = ItemBase.Cast(il.GetItem());
8688 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
8689 int rel_type = il.GetType();
8690 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
8691 {
8692 il.GetParent().GetOnReleaseLock().Invoke(it);
8693 }
8694 else if (rel_type == InventoryLocationType.ATTACHMENT)
8695 {
8696 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
8697 }
8698 //it.GetOnReleaseLock().Invoke(it);
8699 }
8700 }
8701 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
8702 {
8703 //ThrowPhysically(oldPlayer, vector.Zero);
8704 m_ThrowItemOnDrop = false;
8705 }
8706
8707 if (m_OldLocation)
8708 {
8709 m_OldLocation.Reset();
8710 }
8711 }
8712
8713 if (oldLoc.GetType() == InventoryLocationType.TEMP)
8714 {
8715 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
8716 }
8717
8718 if (newLoc.GetType() == InventoryLocationType.TEMP)
8719 {
8720 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
8721 }
8722 }
8723
8724 override void EOnContact(IEntity other, Contact extra)
8725 {
8727 {
8728 int liquidType = -1;
8729 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
8730 if (impactSpeed > 0.0)
8731 {
8732 m_ImpactSpeed = impactSpeed;
8733 #ifndef SERVER
8734 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8735 #else
8736 m_WantPlayImpactSound = true;
8737 SetSynchDirty();
8738 #endif
8739 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
8740 }
8741 }
8742
8743 #ifdef SERVER
8744 if (GetCompEM() && GetCompEM().IsPlugged())
8745 {
8746 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
8747 GetCompEM().UnplugThis();
8748 }
8749 #endif
8750 }
8751
8752 void RefreshPhysics();
8753
8754 override void OnCreatePhysics()
8755 {
8757 }
8758
8759 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8760 {
8761
8762 }
8763 // -------------------------------------------------------------------------
8764 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
8765 {
8766 super.OnItemLocationChanged(old_owner, new_owner);
8767
8768 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
8769 PlayerBase playerNew = PlayerBase.Cast(new_owner);
8770
8771 if (!relatedPlayer && playerNew)
8772 relatedPlayer = playerNew;
8773
8774 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
8775 {
8776 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
8777 if (actionMgr)
8778 {
8779 ActionBase currentAction = actionMgr.GetRunningAction();
8780 if (currentAction)
8781 currentAction.OnItemLocationChanged(this);
8782 }
8783 }
8784
8785 Man ownerPlayerOld = null;
8786 Man ownerPlayerNew = null;
8787
8788 if (old_owner)
8789 {
8790 if (old_owner.IsMan())
8791 {
8792 ownerPlayerOld = Man.Cast(old_owner);
8793 }
8794 else
8795 {
8796 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
8797 }
8798 }
8799 else
8800 {
8801 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
8802 {
8803 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
8804
8805 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
8806 {
8807 GetCompEM().UnplugThis();
8808 }
8809 }
8810 }
8811
8812 if (new_owner)
8813 {
8814 if (new_owner.IsMan())
8815 {
8816 ownerPlayerNew = Man.Cast(new_owner);
8817 }
8818 else
8819 {
8820 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
8821 }
8822 }
8823
8824 if (ownerPlayerOld != ownerPlayerNew)
8825 {
8826 if (ownerPlayerOld)
8827 {
8828 array<EntityAI> subItemsExit = new array<EntityAI>;
8829 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
8830 for (int i = 0; i < subItemsExit.Count(); i++)
8831 {
8832 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
8833 itemExit.OnInventoryExit(ownerPlayerOld);
8834 }
8835 }
8836
8837 if (ownerPlayerNew)
8838 {
8839 array<EntityAI> subItemsEnter = new array<EntityAI>;
8840 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
8841 for (int j = 0; j < subItemsEnter.Count(); j++)
8842 {
8843 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
8844 itemEnter.OnInventoryEnter(ownerPlayerNew);
8845 }
8846 }
8847 }
8848 else if (ownerPlayerNew != null)
8849 {
8850 PlayerBase nplayer;
8851 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
8852 {
8853 array<EntityAI> subItemsUpdate = new array<EntityAI>;
8854 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
8855 for (int k = 0; k < subItemsUpdate.Count(); k++)
8856 {
8857 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
8858 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
8859 }
8860 }
8861 }
8862
8863 if (old_owner)
8864 old_owner.OnChildItemRemoved(this);
8865 if (new_owner)
8866 new_owner.OnChildItemReceived(this);
8867 }
8868
8869 // -------------------------------------------------------------------------------
8870 override void EEDelete(EntityAI parent)
8871 {
8872 super.EEDelete(parent);
8873 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
8874 if (player)
8875 {
8876 OnInventoryExit(player);
8877
8878 if (player.IsAlive())
8879 {
8880 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8881 if (r_index >= 0)
8882 {
8883 InventoryLocation r_il = new InventoryLocation;
8884 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8885
8886 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8887 int r_type = r_il.GetType();
8888 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8889 {
8890 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8891 }
8892 else if (r_type == InventoryLocationType.ATTACHMENT)
8893 {
8894 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8895 }
8896
8897 }
8898
8899 player.RemoveQuickBarEntityShortcut(this);
8900 }
8901 }
8902 }
8903 // -------------------------------------------------------------------------------
8904 override void EEKilled(Object killer)
8905 {
8906 super.EEKilled(killer);
8907
8909 if (killer && killer.IsFireplace() && CanExplodeInFire())
8910 {
8911 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
8912 {
8913 if (IsMagazine())
8914 {
8915 if (Magazine.Cast(this).GetAmmoCount() > 0)
8916 {
8917 ExplodeAmmo();
8918 }
8919 }
8920 else
8921 {
8922 Explode(DamageType.EXPLOSION);
8923 }
8924 }
8925 }
8926 }
8927
8928 override void OnWasAttached(EntityAI parent, int slot_id)
8929 {
8930 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8931
8932 super.OnWasAttached(parent, slot_id);
8933
8934 if (HasQuantity())
8935 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8936
8937 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
8938 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
8939 }
8940
8941 override void OnWasDetached(EntityAI parent, int slot_id)
8942 {
8943 super.OnWasDetached(parent, slot_id);
8944
8945 if (HasQuantity())
8946 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8947
8948 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
8949 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
8950 }
8951
8952 override string ChangeIntoOnAttach(string slot)
8953 {
8954 int idx;
8955 TStringArray inventory_slots = new TStringArray;
8956 TStringArray attach_types = new TStringArray;
8957
8958 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8959 if (inventory_slots.Count() < 1) //is string
8960 {
8961 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
8962 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
8963 }
8964 else //is array
8965 {
8966 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
8967 }
8968
8969 idx = inventory_slots.Find(slot);
8970 if (idx < 0)
8971 return "";
8972
8973 return attach_types.Get(idx);
8974 }
8975
8976 override string ChangeIntoOnDetach()
8977 {
8978 int idx = -1;
8979 string slot;
8980
8981 TStringArray inventory_slots = new TStringArray;
8982 TStringArray detach_types = new TStringArray;
8983
8984 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8985 if (inventory_slots.Count() < 1) //is string
8986 {
8987 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
8988 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8989 }
8990 else //is array
8991 {
8992 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
8993 if (detach_types.Count() < 1)
8994 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8995 }
8996
8997 for (int i = 0; i < inventory_slots.Count(); i++)
8998 {
8999 slot = inventory_slots.Get(i);
9000 }
9001
9002 if (slot != "")
9003 {
9004 if (detach_types.Count() == 1)
9005 idx = 0;
9006 else
9007 idx = inventory_slots.Find(slot);
9008 }
9009 if (idx < 0)
9010 return "";
9011
9012 return detach_types.Get(idx);
9013 }
9014
9015 void ExplodeAmmo()
9016 {
9017 //timer
9018 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
9019
9020 //min/max time
9021 float min_time = 1;
9022 float max_time = 3;
9023 float delay = Math.RandomFloat(min_time, max_time);
9024
9025 explode_timer.Run(delay, this, "DoAmmoExplosion");
9026 }
9027
9028 void DoAmmoExplosion()
9029 {
9030 Magazine magazine = Magazine.Cast(this);
9031 int pop_sounds_count = 6;
9032 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
9033
9034 //play sound
9035 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
9036 string sound_name = pop_sounds[ sound_idx ];
9037 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
9038
9039 //remove ammo count
9040 magazine.ServerAddAmmoCount(-1);
9041
9042 //if condition then repeat -> ExplodeAmmo
9043 float min_temp_to_explode = 100; //min temperature for item to explode
9044
9045 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
9046 {
9047 ExplodeAmmo();
9048 }
9049 }
9050
9051 // -------------------------------------------------------------------------------
9052 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9053 {
9054 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
9055
9056 const int CHANCE_DAMAGE_CARGO = 4;
9057 const int CHANCE_DAMAGE_ATTACHMENT = 1;
9058 const int CHANCE_DAMAGE_NOTHING = 2;
9059
9060 if (IsClothing() || IsContainer() || IsItemTent())
9061 {
9062 float dmg = damageResult.GetDamage("","Health") * -0.5;
9063 int chances;
9064 int rnd;
9065
9066 if (GetInventory().GetCargo())
9067 {
9068 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9069 rnd = Math.RandomInt(0,chances);
9070
9071 if (rnd < CHANCE_DAMAGE_CARGO)
9072 {
9073 DamageItemInCargo(dmg);
9074 }
9075 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9076 {
9078 }
9079 }
9080 else
9081 {
9082 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9083 rnd = Math.RandomInt(0,chances);
9084
9085 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9086 {
9088 }
9089 }
9090 }
9091 }
9092
9093 bool DamageItemInCargo(float damage)
9094 {
9095 CargoBase cargo = GetInventory().GetCargo();
9096 if (cargo)
9097 {
9098 int item_count = cargo.GetItemCount();
9099 if (item_count > 0)
9100 {
9101 int random_pick = Math.RandomInt(0, item_count);
9102 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
9103 if (!item.IsExplosive())
9104 {
9105 item.AddHealth("","",damage);
9106 return true;
9107 }
9108 }
9109 }
9110 return false;
9111 }
9112
9113 bool DamageItemAttachments(float damage)
9114 {
9115 GameInventory inventory = GetInventory();
9116 int attachment_count = inventory.AttachmentCount();
9117 if (attachment_count > 0)
9118 {
9119 int random_pick = Math.RandomInt(0, attachment_count);
9120 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
9121 if (!attachment.IsExplosive())
9122 {
9123 attachment.AddHealth("","",damage);
9124 return true;
9125 }
9126 }
9127 return false;
9128 }
9129
9130 override bool IsSplitable()
9131 {
9132 return m_CanThisBeSplit;
9133 }
9134 //----------------
9135 override bool CanBeSplit()
9136 {
9137 if (IsSplitable() && (GetQuantity() > 1))
9138 return GetInventory().CanRemoveEntity();
9139
9140 return false;
9141 }
9142
9143 protected bool ShouldSplitQuantity(float quantity)
9144 {
9145 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
9146 if (!IsSplitable())
9147 return false;
9148
9149 // nothing to split?
9150 if (GetQuantity() <= 1)
9151 return false;
9152
9153 // check if we should re-use the item instead of creating a new copy?
9154 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
9155 int delta = GetQuantity() - quantity;
9156 if (delta == 0)
9157 return false;
9158
9159 // valid to split
9160 return true;
9161 }
9162
9163 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
9164 {
9165 if (g_Game.IsClient())
9166 {
9167 if (ScriptInputUserData.CanStoreInputUserData())
9168 {
9169 ScriptInputUserData ctx = new ScriptInputUserData;
9171 ctx.Write(1);
9172 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9173 ctx.Write(i1);
9174 ctx.Write(destination_entity);
9175 ctx.Write(true);
9176 ctx.Write(slot_id);
9177 ctx.Send();
9178 }
9179 }
9180 else if (!g_Game.IsMultiplayer())
9181 {
9182 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
9183 }
9184 }
9185
9186 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
9187 {
9188 float split_quantity_new;
9189 ItemBase new_item;
9190 float quantity = GetQuantity();
9191 float stack_max = GetTargetQuantityMax(slot_id);
9192 InventoryLocation loc = new InventoryLocation;
9193
9194 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9195 {
9196 if (stack_max <= GetQuantity())
9197 split_quantity_new = stack_max;
9198 else
9199 split_quantity_new = GetQuantity();
9200
9201 if (ShouldSplitQuantity(split_quantity_new))
9202 {
9203 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9204 if (new_item)
9205 {
9206 new_item.SetResultOfSplit(true);
9207 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9208 AddQuantity(-split_quantity_new, false, true);
9209 new_item.SetQuantity(split_quantity_new, false, true);
9210 }
9211 }
9212 }
9213 else if (destination_entity && slot_id == -1)
9214 {
9215 if (quantity > stack_max)
9216 split_quantity_new = stack_max;
9217 else
9218 split_quantity_new = quantity;
9219
9220 if (ShouldSplitQuantity(split_quantity_new))
9221 {
9222 GameInventory destinationInventory = destination_entity.GetInventory();
9223 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9224 {
9225 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9226 new_item = ItemBase.Cast(o);
9227 }
9228
9229 if (new_item)
9230 {
9231 new_item.SetResultOfSplit(true);
9232 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9233 AddQuantity(-split_quantity_new, false, true);
9234 new_item.SetQuantity(split_quantity_new, false, true);
9235 }
9236 }
9237 }
9238 else
9239 {
9240 if (stack_max != 0)
9241 {
9242 if (stack_max < GetQuantity())
9243 {
9244 split_quantity_new = GetQuantity() - stack_max;
9245 }
9246
9247 if (split_quantity_new == 0)
9248 {
9249 if (!g_Game.IsMultiplayer())
9250 player.PhysicalPredictiveDropItem(this);
9251 else
9252 player.ServerDropEntity(this);
9253 return;
9254 }
9255
9256 if (ShouldSplitQuantity(split_quantity_new))
9257 {
9258 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9259
9260 if (new_item)
9261 {
9262 new_item.SetResultOfSplit(true);
9263 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9264 SetQuantity(split_quantity_new, false, true);
9265 new_item.SetQuantity(stack_max, false, true);
9266 new_item.PlaceOnSurface();
9267 }
9268 }
9269 }
9270 }
9271 }
9272
9273 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
9274 {
9275 float split_quantity_new;
9276 ItemBase new_item;
9277 float quantity = GetQuantity();
9278 float stack_max = GetTargetQuantityMax(slot_id);
9279 InventoryLocation loc = new InventoryLocation;
9280
9281 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9282 {
9283 if (stack_max <= GetQuantity())
9284 split_quantity_new = stack_max;
9285 else
9286 split_quantity_new = GetQuantity();
9287
9288 if (ShouldSplitQuantity(split_quantity_new))
9289 {
9290 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9291 if (new_item)
9292 {
9293 new_item.SetResultOfSplit(true);
9294 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9295 AddQuantity(-split_quantity_new, false, true);
9296 new_item.SetQuantity(split_quantity_new, false, true);
9297 }
9298 }
9299 }
9300 else if (destination_entity && slot_id == -1)
9301 {
9302 if (quantity > stack_max)
9303 split_quantity_new = stack_max;
9304 else
9305 split_quantity_new = quantity;
9306
9307 if (ShouldSplitQuantity(split_quantity_new))
9308 {
9309 GameInventory destinationInventory = destination_entity.GetInventory();
9310 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9311 {
9312 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9313 new_item = ItemBase.Cast(o);
9314 }
9315
9316 if (new_item)
9317 {
9318 new_item.SetResultOfSplit(true);
9319 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9320 AddQuantity(-split_quantity_new, false, true);
9321 new_item.SetQuantity(split_quantity_new, false, true);
9322 }
9323 }
9324 }
9325 else
9326 {
9327 if (stack_max != 0)
9328 {
9329 if (stack_max < GetQuantity())
9330 {
9331 split_quantity_new = GetQuantity() - stack_max;
9332 }
9333
9334 if (ShouldSplitQuantity(split_quantity_new))
9335 {
9336 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9337
9338 if (new_item)
9339 {
9340 new_item.SetResultOfSplit(true);
9341 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9342 SetQuantity(split_quantity_new, false, true);
9343 new_item.SetQuantity(stack_max, false, true);
9344 new_item.PlaceOnSurface();
9345 }
9346 }
9347 }
9348 }
9349 }
9350
9351 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
9352 {
9353 if (g_Game.IsClient())
9354 {
9355 if (ScriptInputUserData.CanStoreInputUserData())
9356 {
9357 ScriptInputUserData ctx = new ScriptInputUserData;
9359 ctx.Write(4);
9360 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9361 ctx.Write(thiz);
9362 dst.WriteToContext(ctx);
9363 ctx.Send();
9364 }
9365 }
9366 else if (!g_Game.IsMultiplayer())
9367 {
9369 }
9370 }
9371
9372 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
9373 {
9374 if (g_Game.IsClient())
9375 {
9376 if (ScriptInputUserData.CanStoreInputUserData())
9377 {
9378 ScriptInputUserData ctx = new ScriptInputUserData;
9380 ctx.Write(2);
9381 ItemBase dummy = this; // @NOTE: workaround for correct serialization
9382 ctx.Write(dummy);
9383 ctx.Write(destination_entity);
9384 ctx.Write(true);
9385 ctx.Write(idx);
9386 ctx.Write(row);
9387 ctx.Write(col);
9388 ctx.Send();
9389 }
9390 }
9391 else if (!g_Game.IsMultiplayer())
9392 {
9393 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
9394 }
9395 }
9396
9397 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
9398 {
9400 }
9401
9402 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
9403 {
9404 float quantity = GetQuantity();
9405 float split_quantity_new;
9406 ItemBase new_item;
9407 if (dst.IsValid())
9408 {
9409 int slot_id = dst.GetSlot();
9410 float stack_max = GetTargetQuantityMax(slot_id);
9411
9412 if (quantity > stack_max)
9413 split_quantity_new = stack_max;
9414 else
9415 split_quantity_new = quantity;
9416
9417 if (ShouldSplitQuantity(split_quantity_new))
9418 {
9419 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9420
9421 if (new_item)
9422 {
9423 new_item.SetResultOfSplit(true);
9424 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9425 AddQuantity(-split_quantity_new, false, true);
9426 new_item.SetQuantity(split_quantity_new, false, true);
9427 }
9428
9429 return new_item;
9430 }
9431 }
9432
9433 return null;
9434 }
9435
9436 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
9437 {
9438 float quantity = GetQuantity();
9439 float split_quantity_new;
9440 ItemBase new_item;
9441 if (destination_entity)
9442 {
9443 float stackable = GetTargetQuantityMax();
9444 if (quantity > stackable)
9445 split_quantity_new = stackable;
9446 else
9447 split_quantity_new = quantity;
9448
9449 if (ShouldSplitQuantity(split_quantity_new))
9450 {
9451 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
9452 if (new_item)
9453 {
9454 new_item.SetResultOfSplit(true);
9455 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9456 AddQuantity(-split_quantity_new, false, true);
9457 new_item.SetQuantity(split_quantity_new, false, true);
9458 }
9459 }
9460 }
9461 }
9462
9463 void SplitIntoStackMaxHandsClient(PlayerBase player)
9464 {
9465 if (g_Game.IsClient())
9466 {
9467 if (ScriptInputUserData.CanStoreInputUserData())
9468 {
9469 ScriptInputUserData ctx = new ScriptInputUserData;
9471 ctx.Write(3);
9472 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9473 ctx.Write(i1);
9474 ItemBase destination_entity = this;
9475 ctx.Write(destination_entity);
9476 ctx.Write(true);
9477 ctx.Write(0);
9478 ctx.Send();
9479 }
9480 }
9481 else if (!g_Game.IsMultiplayer())
9482 {
9483 SplitIntoStackMaxHands(player);
9484 }
9485 }
9486
9487 void SplitIntoStackMaxHands(PlayerBase player)
9488 {
9489 float quantity = GetQuantity();
9490 float split_quantity_new;
9491 ref ItemBase new_item;
9492 if (player)
9493 {
9494 float stackable = GetTargetQuantityMax();
9495 if (quantity > stackable)
9496 split_quantity_new = stackable;
9497 else
9498 split_quantity_new = quantity;
9499
9500 if (ShouldSplitQuantity(split_quantity_new))
9501 {
9502 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
9503 new_item = ItemBase.Cast(in_hands);
9504 if (new_item)
9505 {
9506 new_item.SetResultOfSplit(true);
9507 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9508 AddQuantity(-split_quantity_new, false, true);
9509 new_item.SetQuantity(split_quantity_new, false, true);
9510 }
9511 }
9512 }
9513 }
9514
9515 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
9516 {
9517 float quantity = GetQuantity();
9518 float split_quantity_new = Math.Floor(quantity * 0.5);
9519
9520 if (!ShouldSplitQuantity(split_quantity_new))
9521 return;
9522
9523 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9524
9525 if (new_item)
9526 {
9527 if (new_item.GetQuantityMax() < split_quantity_new)
9528 {
9529 split_quantity_new = new_item.GetQuantityMax();
9530 }
9531
9532 new_item.SetResultOfSplit(true);
9533 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9534
9535 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9536 {
9537 AddQuantity(-1, false, true);
9538 new_item.SetQuantity(1, false, true);
9539 }
9540 else
9541 {
9542 AddQuantity(-split_quantity_new, false, true);
9543 new_item.SetQuantity(split_quantity_new, false, true);
9544 }
9545 }
9546 }
9547
9548 void SplitItem(PlayerBase player)
9549 {
9550 float quantity = GetQuantity();
9551 float split_quantity_new = Math.Floor(quantity / 2);
9552
9553 if (!ShouldSplitQuantity(split_quantity_new))
9554 return;
9555
9556 InventoryLocation invloc = new InventoryLocation;
9557 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
9558
9559 ItemBase new_item;
9560 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
9561
9562 if (new_item)
9563 {
9564 if (new_item.GetQuantityMax() < split_quantity_new)
9565 {
9566 split_quantity_new = new_item.GetQuantityMax();
9567 }
9568 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9569 {
9570 AddQuantity(-1, false, true);
9571 new_item.SetQuantity(1, false, true);
9572 }
9573 else if (split_quantity_new > 1)
9574 {
9575 AddQuantity(-split_quantity_new, false, true);
9576 new_item.SetQuantity(split_quantity_new, false, true);
9577 }
9578 }
9579 }
9580
9582 void OnQuantityChanged(float delta)
9583 {
9584 SetWeightDirty();
9585 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
9586
9587 if (parent)
9588 parent.OnAttachmentQuantityChangedEx(this, delta);
9589
9590 if (IsLiquidContainer())
9591 {
9592 if (GetQuantityNormalized() <= 0.0)
9593 {
9595 }
9596 else if (GetLiquidType() == LIQUID_NONE)
9597 {
9598 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
9600 }
9601 }
9602 }
9603
9606 {
9607 // insert code here
9608 }
9609
9611 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
9612 {
9614 }
9615
9616 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
9617 {
9618 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
9619
9620 if (g_Game.IsServer())
9621 {
9622 if (newLevel == GameConstants.STATE_RUINED)
9623 {
9625 EntityAI parent = GetHierarchyParent();
9626 if (parent && parent.IsFireplace())
9627 {
9628 CargoBase cargo = GetInventory().GetCargo();
9629 if (cargo)
9630 {
9631 for (int i = 0; i < cargo.GetItemCount(); ++i)
9632 {
9633 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
9634 }
9635 }
9636 }
9637 }
9638
9639 if (IsResultOfSplit())
9640 {
9641 // reset the splitting result flag, return to normal item behavior
9642 SetResultOfSplit(false);
9643 return;
9644 }
9645
9646 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
9647 {
9648 SetCleanness(0);//unclean the item upon damage dealt
9649 }
9650 }
9651 }
9652
9653 // just the split? TODO: verify
9654 override void OnRightClick()
9655 {
9656 super.OnRightClick();
9657
9658 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
9659 {
9660 if (g_Game.IsClient())
9661 {
9662 if (ScriptInputUserData.CanStoreInputUserData())
9663 {
9664 EntityAI root = GetHierarchyRoot();
9665 Man playerOwner = GetHierarchyRootPlayer();
9666 InventoryLocation dst = new InventoryLocation;
9667
9668 // 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
9669 if (!playerOwner && root && root == this)
9670 {
9672 }
9673 else
9674 {
9675 // 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
9676 GetInventory().GetCurrentInventoryLocation(dst);
9677 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
9678 {
9679 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9680 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
9681 {
9683 }
9684 else
9685 {
9686 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
9687 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
9688 this shouldnt cause issues within this scope*/
9689 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
9690 {
9692 }
9693 else
9694 {
9695 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
9696 }
9697 }
9698 }
9699 }
9700
9701 ScriptInputUserData ctx = new ScriptInputUserData;
9703 ctx.Write(4);
9704 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9705 ctx.Write(thiz);
9706 dst.WriteToContext(ctx);
9707 ctx.Write(true); // dummy
9708 ctx.Send();
9709 }
9710 }
9711 else if (!g_Game.IsMultiplayer())
9712 {
9713 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
9714 }
9715 }
9716 }
9717
9718 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
9719 {
9720 if (root)
9721 {
9722 vector m4[4];
9723 root.GetTransform(m4);
9724 dst.SetGround(this, m4);
9725 }
9726 else
9727 {
9728 GetInventory().GetCurrentInventoryLocation(dst);
9729 }
9730 }
9731
9732 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
9733 {
9734 //TODO: delete check zero quantity check after fix double posts hands fsm events
9735 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
9736 return false;
9737
9738 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
9739 return false;
9740
9741 //can_this_be_combined = ConfigGetBool("canBeSplit");
9743 return false;
9744
9745
9746 Magazine mag = Magazine.Cast(this);
9747 if (mag)
9748 {
9749 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
9750 return false;
9751
9752 if (stack_max_limit)
9753 {
9754 Magazine other_mag = Magazine.Cast(other_item);
9755 if (other_item)
9756 {
9757 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
9758 return false;
9759 }
9760
9761 }
9762 }
9763 else
9764 {
9765 //TODO: delete check zero quantity check after fix double posts hands fsm events
9766 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
9767 return false;
9768
9769 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
9770 return false;
9771 }
9772
9773 PlayerBase player = null;
9774 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
9775 {
9776 if (player.GetInventory().HasAttachment(this))
9777 return false;
9778
9779 if (player.IsItemsToDelete())
9780 return false;
9781 }
9782
9783 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
9784 return false;
9785
9786 int slotID;
9787 string slotName;
9788 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
9789 return false;
9790
9791 return true;
9792 }
9793
9794 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
9795 {
9796 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
9797 }
9798
9799 bool IsResultOfSplit()
9800 {
9801 return m_IsResultOfSplit;
9802 }
9803
9804 void SetResultOfSplit(bool value)
9805 {
9806 m_IsResultOfSplit = value;
9807 }
9808
9809 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
9810 {
9811 return ComputeQuantityUsedEx(other_item, use_stack_max);
9812 }
9813
9814 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
9815 {
9816 float other_item_quantity = other_item.GetQuantity();
9817 float this_free_space;
9818
9819 float stack_max = GetQuantityMax();
9820
9821 this_free_space = stack_max - GetQuantity();
9822
9823 if (other_item_quantity > this_free_space)
9824 {
9825 return this_free_space;
9826 }
9827 else
9828 {
9829 return other_item_quantity;
9830 }
9831 }
9832
9833 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
9834 {
9835 CombineItems(ItemBase.Cast(entity2),use_stack_max);
9836 }
9837
9838 void CombineItems(ItemBase other_item, bool use_stack_max = true)
9839 {
9840 if (!CanBeCombined(other_item, false))
9841 return;
9842
9843 if (!IsMagazine() && other_item)
9844 {
9845 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
9846 if (quantity_used != 0)
9847 {
9848 float hp1 = GetHealth01("","");
9849 float hp2 = other_item.GetHealth01("","");
9850 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
9851 hpResult = hpResult / (GetQuantity() + quantity_used);
9852
9853 hpResult *= GetMaxHealth();
9854 Math.Round(hpResult);
9855 SetHealth("", "Health", hpResult);
9856
9857 AddQuantity(quantity_used);
9858 other_item.AddQuantity(-quantity_used);
9859 }
9860 }
9861 OnCombine(other_item);
9862 }
9863
9864 void OnCombine(ItemBase other_item)
9865 {
9866 #ifdef SERVER
9867 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
9868 GetHierarchyParent().IncreaseLifetimeUp();
9869 #endif
9870 };
9871
9872 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
9873 {
9874 PlayerBase p = PlayerBase.Cast(player);
9875
9876 array<int> recipesIds = p.m_Recipes;
9877 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9878 if (moduleRecipesManager)
9879 {
9880 EntityAI itemInHands = player.GetEntityInHands();
9881 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
9882 }
9883
9884 for (int i = 0;i < recipesIds.Count(); i++)
9885 {
9886 int key = recipesIds.Get(i);
9887 string recipeName = moduleRecipesManager.GetRecipeName(key);
9888 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
9889 }
9890 }
9891
9892 // -------------------------------------------------------------------------
9893 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
9894 {
9895 super.GetDebugActions(outputList);
9896
9897 //quantity
9898 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
9899 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
9900 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
9901 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
9902 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9903
9904 //health
9905 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
9906 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
9907 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
9908 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9909 //temperature
9910 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
9911 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
9912 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
9913 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9914
9915 //wet
9916 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
9917 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
9918 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9919
9920 //liquidtype
9921 if (IsLiquidContainer())
9922 {
9923 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
9924 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
9925 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9926 }
9927
9928 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
9929 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9930
9931 // watch
9932 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
9933 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
9934 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9935
9936 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
9937
9938 InventoryLocation loc = new InventoryLocation();
9939 GetInventory().GetCurrentInventoryLocation(loc);
9940 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
9941 {
9942 if (Gizmo_IsSupported())
9943 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
9944 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
9945 }
9946
9947 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9948 }
9949
9950 // -------------------------------------------------------------------------
9951 // -------------------------------------------------------------------------
9952 // -------------------------------------------------------------------------
9953 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
9954 {
9955 super.OnAction(action_id, player, ctx);
9956
9957 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
9958 {
9959 switch (action_id)
9960 {
9961 case EActions.GIZMO_OBJECT:
9962 if (GetGizmoApi())
9963 GetGizmoApi().SelectObject(this);
9964 return true;
9965 case EActions.GIZMO_PHYSICS:
9966 if (GetGizmoApi())
9967 GetGizmoApi().SelectPhysics(GetPhysics());
9968 return true;
9969 }
9970 }
9971
9972 if (g_Game.IsServer())
9973 {
9974 switch (action_id)
9975 {
9976 case EActions.DELETE:
9977 Delete();
9978 return true;
9979 }
9980 }
9981
9982 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
9983 {
9984 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9985 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
9986 PlayerBase p = PlayerBase.Cast(player);
9987 if (EActions.RECIPES_RANGE_START < 1000)
9988 {
9989 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
9990 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
9991 }
9992 }
9993 #ifndef SERVER
9994 else if (action_id == EActions.WATCH_PLAYER)
9995 {
9996 PluginDeveloper.SetDeveloperItemClientEx(player);
9997 }
9998 #endif
9999 if (g_Game.IsServer())
10000 {
10001 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
10002 {
10003 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
10004 OnDebugButtonPressServer(id + 1);
10005 }
10006
10007 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
10008 {
10009 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
10010 InsertAgent(agent_id,100);
10011 }
10012
10013 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
10014 {
10015 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
10016 RemoveAgent(agent_id2);
10017 }
10018
10019 else if (action_id == EActions.ADD_QUANTITY)
10020 {
10021 if (IsMagazine())
10022 {
10023 Magazine mag = Magazine.Cast(this);
10024 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
10025 }
10026 else
10027 {
10028 AddQuantity(GetQuantityMax() * 0.2);
10029 }
10030
10031 if (m_EM)
10032 {
10033 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
10034 }
10035 //PrintVariables();
10036 }
10037
10038 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
10039 {
10040 if (IsMagazine())
10041 {
10042 Magazine mag2 = Magazine.Cast(this);
10043 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
10044 }
10045 else
10046 {
10047 AddQuantity(- GetQuantityMax() * 0.2);
10048 }
10049 if (m_EM)
10050 {
10051 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
10052 }
10053 //PrintVariables();
10054 }
10055
10056 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
10057 {
10058 SetQuantity(0);
10059
10060 if (m_EM)
10061 {
10062 m_EM.SetEnergy(0);
10063 }
10064 }
10065
10066 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
10067 {
10069
10070 if (m_EM)
10071 {
10072 m_EM.SetEnergy(m_EM.GetEnergyMax());
10073 }
10074 }
10075
10076 else if (action_id == EActions.ADD_HEALTH)
10077 {
10078 AddHealth("","",GetMaxHealth("","Health")/5);
10079 }
10080 else if (action_id == EActions.REMOVE_HEALTH)
10081 {
10082 AddHealth("","",-GetMaxHealth("","Health")/5);
10083 }
10084 else if (action_id == EActions.DESTROY_HEALTH)
10085 {
10086 SetHealth01("","",0);
10087 }
10088 else if (action_id == EActions.WATCH_ITEM)
10089 {
10091 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10092 #ifdef DEVELOPER
10093 SetDebugDeveloper_item(this);
10094 #endif
10095 }
10096
10097 else if (action_id == EActions.ADD_TEMPERATURE)
10098 {
10099 AddTemperature(20);
10100 //PrintVariables();
10101 }
10102
10103 else if (action_id == EActions.REMOVE_TEMPERATURE)
10104 {
10105 AddTemperature(-20);
10106 //PrintVariables();
10107 }
10108
10109 else if (action_id == EActions.FLIP_FROZEN)
10110 {
10111 SetFrozen(!GetIsFrozen());
10112 //PrintVariables();
10113 }
10114
10115 else if (action_id == EActions.ADD_WETNESS)
10116 {
10117 AddWet(GetWetMax()/5);
10118 //PrintVariables();
10119 }
10120
10121 else if (action_id == EActions.REMOVE_WETNESS)
10122 {
10123 AddWet(-GetWetMax()/5);
10124 //PrintVariables();
10125 }
10126
10127 else if (action_id == EActions.LIQUIDTYPE_UP)
10128 {
10129 int curr_type = GetLiquidType();
10130 SetLiquidType(curr_type * 2);
10131 //AddWet(1);
10132 //PrintVariables();
10133 }
10134
10135 else if (action_id == EActions.LIQUIDTYPE_DOWN)
10136 {
10137 int curr_type2 = GetLiquidType();
10138 SetLiquidType(curr_type2 / 2);
10139 }
10140
10141 else if (action_id == EActions.MAKE_SPECIAL)
10142 {
10143 auto debugParams = DebugSpawnParams.WithPlayer(player);
10144 OnDebugSpawnEx(debugParams);
10145 }
10146
10147 }
10148
10149
10150 return false;
10151 }
10152
10153 // -------------------------------------------------------------------------
10154
10155
10158 void OnActivatedByTripWire();
10159
10161 void OnActivatedByItem(notnull ItemBase item);
10162
10163 //----------------------------------------------------------------
10164 //returns true if item is able to explode when put in fire
10165 bool CanExplodeInFire()
10166 {
10167 return false;
10168 }
10169
10170 //----------------------------------------------------------------
10171 bool CanEat()
10172 {
10173 return true;
10174 }
10175
10176 //----------------------------------------------------------------
10177 override bool IsIgnoredByConstruction()
10178 {
10179 return true;
10180 }
10181
10182 //----------------------------------------------------------------
10183 //has FoodStages in config?
10184 bool HasFoodStage()
10185 {
10186 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
10187 return g_Game.ConfigIsExisting(config_path);
10188 }
10189
10191 FoodStage GetFoodStage()
10192 {
10193 return null;
10194 }
10195
10196 bool CanBeCooked()
10197 {
10198 return false;
10199 }
10200
10201 bool CanBeCookedOnStick()
10202 {
10203 return false;
10204 }
10205
10207 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
10209
10210 //----------------------------------------------------------------
10211 bool CanRepair(ItemBase item_repair_kit)
10212 {
10213 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10214 return module_repairing.CanRepair(this, item_repair_kit);
10215 }
10216
10217 //----------------------------------------------------------------
10218 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
10219 {
10220 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10221 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
10222 }
10223
10224 //----------------------------------------------------------------
10225 int GetItemSize()
10226 {
10227 /*
10228 vector v_size = this.ConfigGetVector("itemSize");
10229 int v_size_x = v_size[0];
10230 int v_size_y = v_size[1];
10231 int size = v_size_x * v_size_y;
10232 return size;
10233 */
10234
10235 return 1;
10236 }
10237
10238 //----------------------------------------------------------------
10239 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10240 bool CanBeMovedOverride()
10241 {
10242 return m_CanBeMovedOverride;
10243 }
10244
10245 //----------------------------------------------------------------
10246 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10247 void SetCanBeMovedOverride(bool setting)
10248 {
10249 m_CanBeMovedOverride = setting;
10250 }
10251
10252 //----------------------------------------------------------------
10260 void MessageToOwnerStatus(string text)
10261 {
10262 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10263
10264 if (player)
10265 {
10266 player.MessageStatus(text);
10267 }
10268 }
10269
10270 //----------------------------------------------------------------
10278 void MessageToOwnerAction(string text)
10279 {
10280 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10281
10282 if (player)
10283 {
10284 player.MessageAction(text);
10285 }
10286 }
10287
10288 //----------------------------------------------------------------
10296 void MessageToOwnerFriendly(string text)
10297 {
10298 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10299
10300 if (player)
10301 {
10302 player.MessageFriendly(text);
10303 }
10304 }
10305
10306 //----------------------------------------------------------------
10314 void MessageToOwnerImportant(string text)
10315 {
10316 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10317
10318 if (player)
10319 {
10320 player.MessageImportant(text);
10321 }
10322 }
10323
10324 override bool IsItemBase()
10325 {
10326 return true;
10327 }
10328
10329 // Checks if item is of questioned kind
10330 override bool KindOf(string tag)
10331 {
10332 bool found = false;
10333 string item_name = this.GetType();
10334 ref TStringArray item_tag_array = new TStringArray;
10335 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
10336
10337 int array_size = item_tag_array.Count();
10338 for (int i = 0; i < array_size; i++)
10339 {
10340 if (item_tag_array.Get(i) == tag)
10341 {
10342 found = true;
10343 break;
10344 }
10345 }
10346 return found;
10347 }
10348
10349
10350 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
10351 {
10352 //Debug.Log("OnRPC called");
10353 super.OnRPC(sender, rpc_type,ctx);
10354
10355 //Play soundset for attachment locking (ActionLockAttachment.c)
10356 switch (rpc_type)
10357 {
10358 #ifndef SERVER
10359 case ERPCs.RPC_SOUND_LOCK_ATTACH:
10360 Param2<bool, string> p = new Param2<bool, string>(false, "");
10361
10362 if (!ctx.Read(p))
10363 return;
10364
10365 bool play = p.param1;
10366 string soundSet = p.param2;
10367
10368 if (play)
10369 {
10370 if (m_LockingSound)
10371 {
10373 {
10374 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10375 }
10376 }
10377 else
10378 {
10379 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10380 }
10381 }
10382 else
10383 {
10384 SEffectManager.DestroyEffect(m_LockingSound);
10385 }
10386
10387 break;
10388 #endif
10389
10390 }
10391
10392 if (GetWrittenNoteData())
10393 {
10394 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
10395 }
10396 }
10397
10398 //-----------------------------
10399 // VARIABLE MANIPULATION SYSTEM
10400 //-----------------------------
10401 int NameToID(string name)
10402 {
10403 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10404 return plugin.GetID(name);
10405 }
10406
10407 string IDToName(int id)
10408 {
10409 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10410 return plugin.GetName(id);
10411 }
10412
10414 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
10415 {
10416 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
10417 //read the flags
10418 int varFlags;
10419 if (!ctx.Read(varFlags))
10420 return;
10421
10422 if (varFlags & ItemVariableFlags.FLOAT)
10423 {
10424 ReadVarsFromCTX(ctx);
10425 }
10426 }
10427
10428 override void SerializeNumericalVars(array<float> floats_out)
10429 {
10430 //some variables handled on EntityAI level already!
10431 super.SerializeNumericalVars(floats_out);
10432
10433 // the order of serialization must be the same as the order of de-serialization
10434 //--------------------------------------------
10435 if (IsVariableSet(VARIABLE_QUANTITY))
10436 {
10437 floats_out.Insert(m_VarQuantity);
10438 }
10439 //--------------------------------------------
10440 if (IsVariableSet(VARIABLE_WET))
10441 {
10442 floats_out.Insert(m_VarWet);
10443 }
10444 //--------------------------------------------
10445 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10446 {
10447 floats_out.Insert(m_VarLiquidType);
10448 }
10449 //--------------------------------------------
10450 if (IsVariableSet(VARIABLE_COLOR))
10451 {
10452 floats_out.Insert(m_ColorComponentR);
10453 floats_out.Insert(m_ColorComponentG);
10454 floats_out.Insert(m_ColorComponentB);
10455 floats_out.Insert(m_ColorComponentA);
10456 }
10457 //--------------------------------------------
10458 if (IsVariableSet(VARIABLE_CLEANNESS))
10459 {
10460 floats_out.Insert(m_Cleanness);
10461 }
10462 }
10463
10464 override void DeSerializeNumericalVars(array<float> floats)
10465 {
10466 //some variables handled on EntityAI level already!
10467 super.DeSerializeNumericalVars(floats);
10468
10469 // the order of serialization must be the same as the order of de-serialization
10470 int index = 0;
10471 int mask = Math.Round(floats.Get(index));
10472
10473 index++;
10474 //--------------------------------------------
10475 if (mask & VARIABLE_QUANTITY)
10476 {
10477 if (m_IsStoreLoad)
10478 {
10479 SetStoreLoadedQuantity(floats.Get(index));
10480 }
10481 else
10482 {
10483 float quantity = floats.Get(index);
10484 SetQuantity(quantity, true, false, false, false);
10485 }
10486 index++;
10487 }
10488 //--------------------------------------------
10489 if (mask & VARIABLE_WET)
10490 {
10491 float wet = floats.Get(index);
10492 SetWet(wet);
10493 index++;
10494 }
10495 //--------------------------------------------
10496 if (mask & VARIABLE_LIQUIDTYPE)
10497 {
10498 int liquidtype = Math.Round(floats.Get(index));
10499 SetLiquidType(liquidtype);
10500 index++;
10501 }
10502 //--------------------------------------------
10503 if (mask & VARIABLE_COLOR)
10504 {
10505 m_ColorComponentR = Math.Round(floats.Get(index));
10506 index++;
10507 m_ColorComponentG = Math.Round(floats.Get(index));
10508 index++;
10509 m_ColorComponentB = Math.Round(floats.Get(index));
10510 index++;
10511 m_ColorComponentA = Math.Round(floats.Get(index));
10512 index++;
10513 }
10514 //--------------------------------------------
10515 if (mask & VARIABLE_CLEANNESS)
10516 {
10517 int cleanness = Math.Round(floats.Get(index));
10518 SetCleanness(cleanness);
10519 index++;
10520 }
10521 }
10522
10523 override void WriteVarsToCTX(ParamsWriteContext ctx)
10524 {
10525 super.WriteVarsToCTX(ctx);
10526
10527 //--------------------------------------------
10528 if (IsVariableSet(VARIABLE_QUANTITY))
10529 {
10530 ctx.Write(GetQuantity());
10531 }
10532 //--------------------------------------------
10533 if (IsVariableSet(VARIABLE_WET))
10534 {
10535 ctx.Write(GetWet());
10536 }
10537 //--------------------------------------------
10538 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10539 {
10540 ctx.Write(GetLiquidType());
10541 }
10542 //--------------------------------------------
10543 if (IsVariableSet(VARIABLE_COLOR))
10544 {
10545 int r,g,b,a;
10546 GetColor(r,g,b,a);
10547 ctx.Write(r);
10548 ctx.Write(g);
10549 ctx.Write(b);
10550 ctx.Write(a);
10551 }
10552 //--------------------------------------------
10553 if (IsVariableSet(VARIABLE_CLEANNESS))
10554 {
10555 ctx.Write(GetCleanness());
10556 }
10557 }
10558
10559 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
10560 {
10561 if (!super.ReadVarsFromCTX(ctx,version))
10562 return false;
10563
10564 int intValue;
10565 float value;
10566
10567 if (version < 140)
10568 {
10569 if (!ctx.Read(intValue))
10570 return false;
10571
10572 m_VariablesMask = intValue;
10573 }
10574
10575 if (m_VariablesMask & VARIABLE_QUANTITY)
10576 {
10577 if (!ctx.Read(value))
10578 return false;
10579
10580 if (IsStoreLoad())
10581 {
10583 }
10584 else
10585 {
10586 SetQuantity(value, true, false, false, false);
10587 }
10588 }
10589 //--------------------------------------------
10590 if (version < 140)
10591 {
10592 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10593 {
10594 if (!ctx.Read(value))
10595 return false;
10596 SetTemperatureDirect(value);
10597 }
10598 }
10599 //--------------------------------------------
10600 if (m_VariablesMask & VARIABLE_WET)
10601 {
10602 if (!ctx.Read(value))
10603 return false;
10604 SetWet(value);
10605 }
10606 //--------------------------------------------
10607 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
10608 {
10609 if (!ctx.Read(intValue))
10610 return false;
10611 SetLiquidType(intValue);
10612 }
10613 //--------------------------------------------
10614 if (m_VariablesMask & VARIABLE_COLOR)
10615 {
10616 int r,g,b,a;
10617 if (!ctx.Read(r))
10618 return false;
10619 if (!ctx.Read(g))
10620 return false;
10621 if (!ctx.Read(b))
10622 return false;
10623 if (!ctx.Read(a))
10624 return false;
10625
10626 SetColor(r,g,b,a);
10627 }
10628 //--------------------------------------------
10629 if (m_VariablesMask & VARIABLE_CLEANNESS)
10630 {
10631 if (!ctx.Read(intValue))
10632 return false;
10633 SetCleanness(intValue);
10634 }
10635 //--------------------------------------------
10636 if (version >= 138 && version < 140)
10637 {
10638 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10639 {
10640 if (!ctx.Read(intValue))
10641 return false;
10642 SetFrozen(intValue);
10643 }
10644 }
10645
10646 return true;
10647 }
10648
10649 //----------------------------------------------------------------
10650 override bool OnStoreLoad(ParamsReadContext ctx, int version)
10651 {
10652 m_IsStoreLoad = true;
10654 {
10655 m_FixDamageSystemInit = true;
10656 }
10657
10658 if (!super.OnStoreLoad(ctx, version))
10659 {
10660 m_IsStoreLoad = false;
10661 return false;
10662 }
10663
10664 if (version >= 114)
10665 {
10666 bool hasQuickBarIndexSaved;
10667
10668 if (!ctx.Read(hasQuickBarIndexSaved))
10669 {
10670 m_IsStoreLoad = false;
10671 return false;
10672 }
10673
10674 if (hasQuickBarIndexSaved)
10675 {
10676 int itmQBIndex;
10677
10678 //Load quickbar item bind
10679 if (!ctx.Read(itmQBIndex))
10680 {
10681 m_IsStoreLoad = false;
10682 return false;
10683 }
10684
10685 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
10686 if (itmQBIndex != -1 && parentPlayer)
10687 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
10688 }
10689 }
10690 else
10691 {
10692 // Backup of how it used to be
10693 PlayerBase player;
10694 int itemQBIndex;
10695 if (version == int.MAX)
10696 {
10697 if (!ctx.Read(itemQBIndex))
10698 {
10699 m_IsStoreLoad = false;
10700 return false;
10701 }
10702 }
10703 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
10704 {
10705 //Load quickbar item bind
10706 if (!ctx.Read(itemQBIndex))
10707 {
10708 m_IsStoreLoad = false;
10709 return false;
10710 }
10711 if (itemQBIndex != -1 && player)
10712 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
10713 }
10714 }
10715
10716 if (version < 140)
10717 {
10718 // variable management system
10719 if (!LoadVariables(ctx, version))
10720 {
10721 m_IsStoreLoad = false;
10722 return false;
10723 }
10724 }
10725
10726 //agent trasmission system
10727 if (!LoadAgents(ctx, version))
10728 {
10729 m_IsStoreLoad = false;
10730 return false;
10731 }
10732 if (version >= 132)
10733 {
10734 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10735 if (raib)
10736 {
10737 if (!raib.OnStoreLoad(ctx,version))
10738 {
10739 m_IsStoreLoad = false;
10740 return false;
10741 }
10742 }
10743 }
10744
10745 m_IsStoreLoad = false;
10746 return true;
10747 }
10748
10749 //----------------------------------------------------------------
10750
10751 override void OnStoreSave(ParamsWriteContext ctx)
10752 {
10753 super.OnStoreSave(ctx);
10754
10755 PlayerBase player;
10756 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
10757 {
10758 ctx.Write(true); // Keep track of if we should actually read this in or not
10759 //Save quickbar item bind
10760 int itemQBIndex = -1;
10761 itemQBIndex = player.FindQuickBarEntityIndex(this);
10762 ctx.Write(itemQBIndex);
10763 }
10764 else
10765 {
10766 ctx.Write(false); // Keep track of if we should actually read this in or not
10767 }
10768
10769 SaveAgents(ctx);//agent trasmission system
10770
10771 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10772 if (raib)
10773 {
10774 raib.OnStoreSave(ctx);
10775 }
10776 }
10777 //----------------------------------------------------------------
10778
10779 override void AfterStoreLoad()
10780 {
10781 super.AfterStoreLoad();
10782
10784 {
10786 }
10787
10788 if (GetStoreLoadedQuantity() != float.LOWEST)
10789 {
10791 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
10792 }
10793 }
10794
10795 override void EEOnAfterLoad()
10796 {
10797 super.EEOnAfterLoad();
10798
10800 {
10801 m_FixDamageSystemInit = false;
10802 }
10803
10806 }
10807
10808 bool CanBeDisinfected()
10809 {
10810 return false;
10811 }
10812
10813
10814 //----------------------------------------------------------------
10815 override void OnVariablesSynchronized()
10816 {
10817 if (m_Initialized)
10818 {
10819 #ifdef PLATFORM_CONSOLE
10820 //bruteforce it is
10821 if (IsSplitable())
10822 {
10823 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
10824 if (menu)
10825 {
10826 menu.Refresh();
10827 }
10828 }
10829 #endif
10830 }
10831
10833 {
10834 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10835 m_WantPlayImpactSound = false;
10836 }
10837
10839 {
10840 SetWeightDirty();
10842 }
10843 if (m_VarWet != m_VarWetPrev)
10844 {
10847 }
10848
10849 if (m_SoundSyncPlay != 0)
10850 {
10853
10854 m_SoundSyncPlay = 0;
10855 m_SoundSyncSlotID = -1;
10856 }
10857 if (m_SoundSyncStop != 0)
10858 {
10860 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
10861 m_SoundSyncStop = 0;
10862 }
10863
10864 super.OnVariablesSynchronized();
10865 }
10866
10867 //------------------------- Quantity
10868 //----------------------------------------------------------------
10870 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
10871 {
10872 if (!IsServerCheck(allow_client))
10873 return false;
10874
10875 if (!HasQuantity())
10876 return false;
10877
10878 float min = GetQuantityMin();
10879 float max = GetQuantityMax();
10880
10881 if (value <= (min + 0.001))
10882 value = min;
10883
10884 if (value == min)
10885 {
10886 if (destroy_config)
10887 {
10888 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
10889 if (dstr)
10890 {
10891 m_VarQuantity = Math.Clamp(value, min, max);
10892 this.Delete();
10893 return true;
10894 }
10895 }
10896 else if (destroy_forced)
10897 {
10898 m_VarQuantity = Math.Clamp(value, min, max);
10899 this.Delete();
10900 return true;
10901 }
10902 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
10903 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
10904 }
10905
10906 float delta = m_VarQuantity;
10907 m_VarQuantity = Math.Clamp(value, min, max);
10908
10909 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10910 {
10911 EntityAI parent = GetHierarchyRoot();
10912 InventoryLocation iLoc = new InventoryLocation();
10913 GetInventory().GetCurrentInventoryLocation(iLoc);
10914 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
10915 {
10916 int iLocSlot = iLoc.GetSlot();
10917 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
10918 {
10919 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
10920 }
10921 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
10922 {
10923 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
10924 }
10925 }
10926 }
10927
10928 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
10929 {
10930 delta = m_VarQuantity - delta;
10931
10932 if (delta)
10933 OnQuantityChanged(delta);
10934 }
10935
10936 SetVariableMask(VARIABLE_QUANTITY);
10937
10938 return false;
10939 }
10940
10941 //----------------------------------------------------------------
10943 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
10944 {
10945 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
10946 }
10947 //----------------------------------------------------------------
10948 void SetQuantityMax()
10949 {
10950 float max = GetQuantityMax();
10951 SetQuantity(max);
10952 }
10953
10954 override void SetQuantityToMinimum()
10955 {
10956 float min = GetQuantityMin();
10957 SetQuantity(min);
10958 }
10959 //----------------------------------------------------------------
10961 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
10962 {
10963 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
10964 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
10965 SetQuantity(result, destroy_config, destroy_forced);
10966 }
10967
10968 //----------------------------------------------------------------
10970 override float GetQuantityNormalized()
10971 {
10972 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
10973 }
10974
10976 {
10977 return GetQuantityNormalized();
10978 }
10979
10980 /*void SetAmmoNormalized(float value)
10981 {
10982 float value_clamped = Math.Clamp(value, 0, 1);
10983 Magazine this_mag = Magazine.Cast(this);
10984 int max_rounds = this_mag.GetAmmoMax();
10985 int result = value * max_rounds;//can the rounded if higher precision is required
10986 this_mag.SetAmmoCount(result);
10987 }*/
10988 //----------------------------------------------------------------
10989 override int GetQuantityMax()
10990 {
10991 int slot = -1;
10992 GameInventory inventory = GetInventory();
10993 if (inventory)
10994 {
10995 InventoryLocation il = new InventoryLocation;
10996 inventory.GetCurrentInventoryLocation(il);
10997 slot = il.GetSlot();
10998 }
10999
11000 return GetTargetQuantityMax(slot);
11001 }
11002
11003 override int GetTargetQuantityMax(int attSlotID = -1)
11004 {
11005 float quantity_max = 0;
11006
11007 if (IsSplitable()) //only stackable/splitable items can check for stack size
11008 {
11009 if (attSlotID != -1)
11010 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
11011
11012 if (quantity_max <= 0)
11013 quantity_max = m_VarStackMax;
11014 }
11015
11016 if (quantity_max <= 0)
11017 quantity_max = m_VarQuantityMax;
11018
11019 return quantity_max;
11020 }
11021 //----------------------------------------------------------------
11022 override int GetQuantityMin()
11023 {
11024 return m_VarQuantityMin;
11025 }
11026 //----------------------------------------------------------------
11027 int GetQuantityInit()
11028 {
11029 return m_VarQuantityInit;
11030 }
11031
11032 //----------------------------------------------------------------
11033 override bool HasQuantity()
11034 {
11035 return !(GetQuantityMax() - GetQuantityMin() == 0);
11036 }
11037
11038 override float GetQuantity()
11039 {
11040 return m_VarQuantity;
11041 }
11042
11043 bool IsFullQuantity()
11044 {
11045 return GetQuantity() >= GetQuantityMax();
11046 }
11047
11048 //Calculates weight of single item without attachments and cargo
11049 override float GetSingleInventoryItemWeightEx()
11050 {
11051 //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
11052 float weightEx = GetWeightEx();//overall weight of the item
11053 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
11054 return weightEx - special;
11055 }
11056
11057 // Obsolete, use GetSingleInventoryItemWeightEx() instead
11059 {
11061 }
11062
11063 override protected float GetWeightSpecialized(bool forceRecalc = false)
11064 {
11065 if (IsSplitable()) //quantity determines size of the stack
11066 {
11067 #ifdef DEVELOPER
11068 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11069 {
11070 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
11071 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
11072 }
11073 #endif
11074
11075 return GetQuantity() * GetConfigWeightModified();
11076 }
11077 else if (HasEnergyManager())// items with energy manager
11078 {
11079 #ifdef DEVELOPER
11080 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11081 {
11082 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
11083 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
11084 }
11085 #endif
11086 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11087 }
11088 else//everything else
11089 {
11090 #ifdef DEVELOPER
11091 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11092 {
11093 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
11094 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
11095 }
11096 #endif
11097 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11098 }
11099 }
11100
11102 int GetNumberOfItems()
11103 {
11104 int item_count = 0;
11105 ItemBase item;
11106
11107 GameInventory inventory = GetInventory();
11108 CargoBase cargo = inventory.GetCargo();
11109 if (cargo != NULL)
11110 {
11111 item_count = cargo.GetItemCount();
11112 }
11113
11114 int nAttachments = inventory.AttachmentCount();
11115 for (int i = 0; i < nAttachments; ++i)
11116 {
11117 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
11118 if (item)
11119 item_count += item.GetNumberOfItems();
11120 }
11121 return item_count;
11122 }
11123
11125 float GetUnitWeight(bool include_wetness = true)
11126 {
11127 float weight = 0;
11128 float wetness = 1;
11129 if (include_wetness)
11130 wetness += GetWet();
11131 if (IsSplitable()) //quantity determines size of the stack
11132 {
11133 weight = wetness * m_ConfigWeight;
11134 }
11135 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
11136 {
11137 weight = 1;
11138 }
11139 return weight;
11140 }
11141
11142 //-----------------------------------------------------------------
11143
11144 override void ClearInventory()
11145 {
11146 GameInventory inventory = GetInventory();
11147 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
11148 {
11149 array<EntityAI> items = new array<EntityAI>;
11150 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
11151 for (int i = 0; i < items.Count(); ++i)
11152 {
11153 ItemBase item = ItemBase.Cast(items.Get(i));
11154 if (item)
11155 {
11156 g_Game.ObjectDelete(item);
11157 }
11158 }
11159 }
11160 }
11161
11162 //------------------------- Energy
11163
11164 //----------------------------------------------------------------
11165 float GetEnergy()
11166 {
11167 float energy = 0;
11168 if (HasEnergyManager())
11169 {
11170 energy = GetCompEM().GetEnergy();
11171 }
11172 return energy;
11173 }
11174
11175
11176 override void OnEnergyConsumed()
11177 {
11178 super.OnEnergyConsumed();
11179
11181 }
11182
11183 override void OnEnergyAdded()
11184 {
11185 super.OnEnergyAdded();
11186
11188 }
11189
11190 // Converts energy (from Energy Manager) to quantity, if enabled.
11192 {
11193 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
11194 {
11195 if (HasQuantity())
11196 {
11197 float energy_0to1 = GetCompEM().GetEnergy0To1();
11198 SetQuantityNormalized(energy_0to1);
11199 }
11200 }
11201 }
11202
11203 //----------------------------------------------------------------
11204 float GetHeatIsolationInit()
11205 {
11206 return ConfigGetFloat("heatIsolation");
11207 }
11208
11209 float GetHeatIsolation()
11210 {
11211 return m_HeatIsolation;
11212 }
11213
11214 float GetDryingIncrement(string pIncrementName)
11215 {
11216 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
11217 if (g_Game.ConfigIsExisting(paramPath))
11218 return g_Game.ConfigGetFloat(paramPath);
11219
11220 return 0.0;
11221 }
11222
11223 float GetSoakingIncrement(string pIncrementName)
11224 {
11225 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
11226 if (g_Game.ConfigIsExisting(paramPath))
11227 return g_Game.ConfigGetFloat(paramPath);
11228
11229 return 0.0;
11230 }
11231 //----------------------------------------------------------------
11232 override void SetWet(float value, bool allow_client = false)
11233 {
11234 if (!IsServerCheck(allow_client))
11235 return;
11236
11237 float min = GetWetMin();
11238 float max = GetWetMax();
11239
11240 float previousValue = m_VarWet;
11241
11242 m_VarWet = Math.Clamp(value, min, max);
11243
11244 if (previousValue != m_VarWet)
11245 {
11246 SetVariableMask(VARIABLE_WET);
11247 OnWetChanged(m_VarWet, previousValue);
11248 }
11249 }
11250 //----------------------------------------------------------------
11251 override void AddWet(float value)
11252 {
11253 SetWet(GetWet() + value);
11254 }
11255 //----------------------------------------------------------------
11256 override void SetWetMax()
11257 {
11259 }
11260 //----------------------------------------------------------------
11261 override float GetWet()
11262 {
11263 return m_VarWet;
11264 }
11265 //----------------------------------------------------------------
11266 override float GetWetMax()
11267 {
11268 return m_VarWetMax;
11269 }
11270 //----------------------------------------------------------------
11271 override float GetWetMin()
11272 {
11273 return m_VarWetMin;
11274 }
11275 //----------------------------------------------------------------
11276 override float GetWetInit()
11277 {
11278 return m_VarWetInit;
11279 }
11280 //----------------------------------------------------------------
11281 override void OnWetChanged(float newVal, float oldVal)
11282 {
11283 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
11284 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
11285 if (newLevel != oldLevel)
11286 {
11287 OnWetLevelChanged(newLevel,oldLevel);
11288 }
11289 }
11290
11291 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
11292 {
11293 SetWeightDirty();
11294 }
11295
11296 override EWetnessLevel GetWetLevel()
11297 {
11298 return GetWetLevelInternal(m_VarWet);
11299 }
11300
11301 //----------------------------------------------------------------
11302
11303 override void SetStoreLoad(bool value)
11304 {
11305 m_IsStoreLoad = value;
11306 }
11307
11308 override bool IsStoreLoad()
11309 {
11310 return m_IsStoreLoad;
11311 }
11312
11313 override void SetStoreLoadedQuantity(float value)
11314 {
11315 m_StoreLoadedQuantity = value;
11316 }
11317
11318 override float GetStoreLoadedQuantity()
11319 {
11320 return m_StoreLoadedQuantity;
11321 }
11322
11323 //----------------------------------------------------------------
11324
11325 float GetItemModelLength()
11326 {
11327 if (ConfigIsExisting("itemModelLength"))
11328 {
11329 return ConfigGetFloat("itemModelLength");
11330 }
11331 return 0;
11332 }
11333
11334 float GetItemAttachOffset()
11335 {
11336 if (ConfigIsExisting("itemAttachOffset"))
11337 {
11338 return ConfigGetFloat("itemAttachOffset");
11339 }
11340 return 0;
11341 }
11342
11343 override void SetCleanness(int value, bool allow_client = false)
11344 {
11345 if (!IsServerCheck(allow_client))
11346 return;
11347
11348 int previousValue = m_Cleanness;
11349
11350 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
11351
11352 if (previousValue != m_Cleanness)
11353 SetVariableMask(VARIABLE_CLEANNESS);
11354 }
11355
11356 override int GetCleanness()
11357 {
11358 return m_Cleanness;
11359 }
11360
11362 {
11363 return true;
11364 }
11365
11366 //----------------------------------------------------------------
11367 // ATTACHMENT LOCKING
11368 // Getters relevant to generic ActionLockAttachment
11369 int GetLockType()
11370 {
11371 return m_LockType;
11372 }
11373
11374 string GetLockSoundSet()
11375 {
11376 return m_LockSoundSet;
11377 }
11378
11379 //----------------------------------------------------------------
11380 //------------------------- Color
11381 // sets items color variable given color components
11382 override void SetColor(int r, int g, int b, int a)
11383 {
11388 SetVariableMask(VARIABLE_COLOR);
11389 }
11391 override void GetColor(out int r,out int g,out int b,out int a)
11392 {
11397 }
11398
11399 bool IsColorSet()
11400 {
11401 return IsVariableSet(VARIABLE_COLOR);
11402 }
11403
11405 string GetColorString()
11406 {
11407 int r,g,b,a;
11408 GetColor(r,g,b,a);
11409 r = r/255;
11410 g = g/255;
11411 b = b/255;
11412 a = a/255;
11413 return MiscGameplayFunctions.GetColorString(r, g, b, a);
11414 }
11415 //----------------------------------------------------------------
11416 //------------------------- LiquidType
11417
11418 override void SetLiquidType(int value, bool allow_client = false)
11419 {
11420 if (!IsServerCheck(allow_client))
11421 return;
11422
11423 int old = m_VarLiquidType;
11424 m_VarLiquidType = value;
11425 OnLiquidTypeChanged(old,value);
11426 SetVariableMask(VARIABLE_LIQUIDTYPE);
11427 }
11428
11429 int GetLiquidTypeInit()
11430 {
11431 return ConfigGetInt("varLiquidTypeInit");
11432 }
11433
11434 override int GetLiquidType()
11435 {
11436 return m_VarLiquidType;
11437 }
11438
11439 protected void OnLiquidTypeChanged(int oldType, int newType)
11440 {
11441 if (newType == LIQUID_NONE && GetIsFrozen())
11442 SetFrozen(false);
11443 }
11444
11446 void UpdateQuickbarShortcutVisibility(PlayerBase player)
11447 {
11448 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11449 }
11450
11451 // -------------------------------------------------------------------------
11453 void OnInventoryEnter(Man player)
11454 {
11455 PlayerBase nplayer;
11456 if (PlayerBase.CastTo(nplayer, player))
11457 {
11458 m_CanPlayImpactSound = true;
11459 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11460 }
11461 }
11462
11463 // -------------------------------------------------------------------------
11465 void OnInventoryExit(Man player)
11466 {
11467 PlayerBase nplayer;
11468 if (PlayerBase.CastTo(nplayer,player))
11469 {
11470 nplayer.SetEnableQuickBarEntityShortcut(this, false);
11471 }
11472
11473 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
11474
11475 if (HasEnergyManager())
11476 {
11477 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
11478 }
11479 }
11480
11481 // ADVANCED PLACEMENT EVENTS
11482 override void OnPlacementStarted(Man player)
11483 {
11484 super.OnPlacementStarted(player);
11485
11486 SetTakeable(false);
11487 }
11488
11489 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
11490 {
11491 if (m_AdminLog)
11492 {
11493 m_AdminLog.OnPlacementComplete(player, this);
11494 }
11495
11496 super.OnPlacementComplete(player, position, orientation);
11497 }
11498
11499 //-----------------------------
11500 // AGENT SYSTEM
11501 //-----------------------------
11502 //--------------------------------------------------------------------------
11503 bool ContainsAgent(int agent_id)
11504 {
11505 if (agent_id & m_AttachedAgents)
11506 {
11507 return true;
11508 }
11509 else
11510 {
11511 return false;
11512 }
11513 }
11514
11515 //--------------------------------------------------------------------------
11516 override void RemoveAgent(int agent_id)
11517 {
11518 if (ContainsAgent(agent_id))
11519 {
11520 m_AttachedAgents = ~agent_id & m_AttachedAgents;
11521 }
11522 }
11523
11524 //--------------------------------------------------------------------------
11525 override void RemoveAllAgents()
11526 {
11527 m_AttachedAgents = 0;
11528 }
11529 //--------------------------------------------------------------------------
11530 override void RemoveAllAgentsExcept(int agent_to_keep)
11531 {
11532 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
11533 }
11534 // -------------------------------------------------------------------------
11535 override void InsertAgent(int agent, float count = 1)
11536 {
11537 if (count < 1)
11538 return;
11539 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
11541 }
11542
11544 void TransferAgents(int agents)
11545 {
11547 }
11548
11549 // -------------------------------------------------------------------------
11550 override int GetAgents()
11551 {
11552 return m_AttachedAgents;
11553 }
11554 //----------------------------------------------------------------------
11555
11556 /*int GetContaminationType()
11557 {
11558 int contamination_type;
11559
11560 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
11561 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
11562 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
11563 const int DIRTY_MASK = eAgents.WOUND_AGENT;
11564
11565 Edible_Base edible = Edible_Base.Cast(this);
11566 int agents = GetAgents();
11567 if (edible)
11568 {
11569 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
11570 if (profile)
11571 {
11572 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
11573 }
11574 }
11575 if (agents & CONTAMINATED_MASK)
11576 {
11577 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
11578 }
11579 if (agents & POISONED_MASK)
11580 {
11581 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
11582 }
11583 if (agents & NERVE_GAS_MASK)
11584 {
11585 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
11586 }
11587 if (agents & DIRTY_MASK)
11588 {
11589 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
11590 }
11591
11592 return agents;
11593 }*/
11594
11595 // -------------------------------------------------------------------------
11596 bool LoadAgents(ParamsReadContext ctx, int version)
11597 {
11598 if (!ctx.Read(m_AttachedAgents))
11599 return false;
11600 return true;
11601 }
11602 // -------------------------------------------------------------------------
11604 {
11605
11607 }
11608 // -------------------------------------------------------------------------
11609
11611 override void CheckForRoofLimited(float timeTresholdMS = 3000)
11612 {
11613 super.CheckForRoofLimited(timeTresholdMS);
11614
11615 float time = g_Game.GetTime();
11616 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
11617 {
11618 m_PreviousRoofTestTime = time;
11619 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
11620 }
11621 }
11622
11623 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
11624 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
11625 {
11626 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
11627 {
11628 return 0;
11629 }
11630
11631 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
11632 {
11633 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
11634 if (filter)
11635 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
11636 else
11637 return 0;//otherwise return 0 when no filter attached
11638 }
11639
11640 string subclassPath, entryName;
11641
11642 switch (type)
11643 {
11644 case DEF_BIOLOGICAL:
11645 entryName = "biological";
11646 break;
11647 case DEF_CHEMICAL:
11648 entryName = "chemical";
11649 break;
11650 default:
11651 entryName = "biological";
11652 break;
11653 }
11654
11655 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
11656
11657 return g_Game.ConfigGetFloat(subclassPath + entryName);
11658 }
11659
11660
11661
11663 override void EEOnCECreate()
11664 {
11665 if (!IsMagazine())
11667
11669 }
11670
11671
11672 //-------------------------
11673 // OPEN/CLOSE USER ACTIONS
11674 //-------------------------
11676 void Open();
11677 void Close();
11678 bool IsOpen()
11679 {
11680 return true;
11681 }
11682
11683 override bool CanDisplayCargo()
11684 {
11685 return IsOpen();
11686 }
11687
11688
11689 // ------------------------------------------------------------
11690 // CONDITIONS
11691 // ------------------------------------------------------------
11692 override bool CanPutInCargo(EntityAI parent)
11693 {
11694 if (parent)
11695 {
11696 if (parent.IsInherited(DayZInfected))
11697 return true;
11698
11699 if (!parent.IsRuined())
11700 return true;
11701 }
11702
11703 return true;
11704 }
11705
11706 override bool CanPutAsAttachment(EntityAI parent)
11707 {
11708 if (!super.CanPutAsAttachment(parent))
11709 {
11710 return false;
11711 }
11712
11713 if (!IsRuined() && !parent.IsRuined())
11714 {
11715 return true;
11716 }
11717
11718 return false;
11719 }
11720
11721 override bool CanReceiveItemIntoCargo(EntityAI item)
11722 {
11723 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11724 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11725 // return false;
11726
11727 return super.CanReceiveItemIntoCargo(item);
11728 }
11729
11730 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
11731 {
11732 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11733 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11734 // return false;
11735
11736 GameInventory attachmentInv = attachment.GetInventory();
11737 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11738 {
11739 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11740 return false;
11741 }
11742
11743 InventoryLocation loc = new InventoryLocation();
11744 attachment.GetInventory().GetCurrentInventoryLocation(loc);
11745 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
11746 return false;
11747
11748 return super.CanReceiveAttachment(attachment, slotId);
11749 }
11750
11751 override bool CanReleaseAttachment(EntityAI attachment)
11752 {
11753 if (!super.CanReleaseAttachment(attachment))
11754 return false;
11755
11756 return GetInventory().AreChildrenAccessible();
11757 }
11758
11759 /*override bool CanLoadAttachment(EntityAI attachment)
11760 {
11761 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11762 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11763 // return false;
11764
11765 GameInventory attachmentInv = attachment.GetInventory();
11766 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11767 {
11768 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
11769 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
11770
11771 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11772 return false;
11773 }
11774
11775 return super.CanLoadAttachment(attachment);
11776 }*/
11777
11778 // Plays muzzle flash particle effects
11779 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11780 {
11781 int id = muzzle_owner.GetMuzzleID();
11782 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
11783
11784 if (WPOF_array)
11785 {
11786 for (int i = 0; i < WPOF_array.Count(); i++)
11787 {
11788 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
11789
11790 if (WPOF)
11791 {
11792 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
11793 }
11794 }
11795 }
11796 }
11797
11798 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
11799 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11800 {
11801 int id = muzzle_owner.GetMuzzleID();
11802 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
11803
11804 if (WPOBE_array)
11805 {
11806 for (int i = 0; i < WPOBE_array.Count(); i++)
11807 {
11808 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
11809
11810 if (WPOBE)
11811 {
11812 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11813 }
11814 }
11815 }
11816 }
11817
11818 // Plays all weapon overheating particles
11819 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11820 {
11821 int id = muzzle_owner.GetMuzzleID();
11822 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11823
11824 if (WPOOH_array)
11825 {
11826 for (int i = 0; i < WPOOH_array.Count(); i++)
11827 {
11828 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11829
11830 if (WPOOH)
11831 {
11832 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11833 }
11834 }
11835 }
11836 }
11837
11838 // Updates all weapon overheating particles
11839 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11840 {
11841 int id = muzzle_owner.GetMuzzleID();
11842 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11843
11844 if (WPOOH_array)
11845 {
11846 for (int i = 0; i < WPOOH_array.Count(); i++)
11847 {
11848 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11849
11850 if (WPOOH)
11851 {
11852 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11853 }
11854 }
11855 }
11856 }
11857
11858 // Stops overheating particles
11859 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11860 {
11861 int id = muzzle_owner.GetMuzzleID();
11862 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11863
11864 if (WPOOH_array)
11865 {
11866 for (int i = 0; i < WPOOH_array.Count(); i++)
11867 {
11868 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11869
11870 if (WPOOH)
11871 {
11872 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11873 }
11874 }
11875 }
11876 }
11877
11878 //----------------------------------------------------------------
11879 //Item Behaviour - unified approach
11880 override bool IsHeavyBehaviour()
11881 {
11882 if (m_ItemBehaviour == 0)
11883 {
11884 return true;
11885 }
11886
11887 return false;
11888 }
11889
11890 override bool IsOneHandedBehaviour()
11891 {
11892 if (m_ItemBehaviour == 1)
11893 {
11894 return true;
11895 }
11896
11897 return false;
11898 }
11899
11900 override bool IsTwoHandedBehaviour()
11901 {
11902 if (m_ItemBehaviour == 2)
11903 {
11904 return true;
11905 }
11906
11907 return false;
11908 }
11909
11910 bool IsDeployable()
11911 {
11912 return false;
11913 }
11914
11916 float GetDeployTime()
11917 {
11918 return UATimeSpent.DEFAULT_DEPLOY;
11919 }
11920
11921
11922 //----------------------------------------------------------------
11923 // Item Targeting (User Actions)
11924 override void SetTakeable(bool pState)
11925 {
11926 m_IsTakeable = pState;
11927 SetSynchDirty();
11928 }
11929
11930 override bool IsTakeable()
11931 {
11932 return m_IsTakeable;
11933 }
11934
11935 // For cases where we want to show object widget which cant be taken to hands
11937 {
11938 return false;
11939 }
11940
11942 protected void PreLoadSoundAttachmentType()
11943 {
11944 string att_type = "None";
11945
11946 if (ConfigIsExisting("soundAttType"))
11947 {
11948 att_type = ConfigGetString("soundAttType");
11949 }
11950
11951 m_SoundAttType = att_type;
11952 }
11953
11954 override string GetAttachmentSoundType()
11955 {
11956 return m_SoundAttType;
11957 }
11958
11959 //----------------------------------------------------------------
11960 //SOUNDS - ItemSoundHandler
11961 //----------------------------------------------------------------
11962
11963 string GetPlaceSoundset(); // played when deploy starts
11964 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
11965 string GetDeploySoundset(); // played when deploy sucessfully finishes
11966 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
11967 string GetFoldSoundset(); // played when fold sucessfully finishes
11968
11970 {
11971 if (!m_ItemSoundHandler)
11973
11974 return m_ItemSoundHandler;
11975 }
11976
11977 // override to initialize sounds
11978 protected void InitItemSounds()
11979 {
11980 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
11981 return;
11982
11984
11985 if (GetPlaceSoundset() != string.Empty)
11986 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
11987
11988 if (GetDeploySoundset() != string.Empty)
11989 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
11990
11991 SoundParameters params = new SoundParameters();
11992 params.m_Loop = true;
11993 if (GetLoopDeploySoundset() != string.Empty)
11994 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
11995 }
11996
11997 // Start sound using ItemSoundHandler
11998 void StartItemSoundServer(int id, int slotId)
11999 {
12000 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12001 {
12002 m_SoundSyncSlotID = slotId;
12003 m_SoundSyncPlay = id;
12004
12005 SetSynchDirty();
12006
12007 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
12008 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
12009 }
12010 }
12011
12012 void StartItemSoundServer(int id)
12013 {
12014 StartItemSoundServer(id, InventorySlots.INVALID);
12015 }
12016
12017 // Stop sound using ItemSoundHandler
12018 void StopItemSoundServer(int id)
12019 {
12020 if (!g_Game.IsServer())
12021 return;
12022
12023 m_SoundSyncStop = id;
12024 SetSynchDirty();
12025
12026 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
12027 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
12028 }
12029
12030 protected void ClearStartItemSoundServer()
12031 {
12032 m_SoundSyncPlay = 0;
12033 m_SoundSyncSlotID = InventorySlots.INVALID;
12034 }
12035
12036 protected void ClearStopItemSoundServer()
12037 {
12038 m_SoundSyncStop = 0;
12039 }
12040
12041 void OnApply(PlayerBase player);
12042
12044 {
12045 return 1.0;
12046 };
12047 //returns applicable selection
12048 array<string> GetHeadHidingSelection()
12049 {
12051 }
12052
12054 {
12056 }
12057
12058 WrittenNoteData GetWrittenNoteData() {};
12059
12061 {
12062 SetDynamicPhysicsLifeTime(0.01);
12063 m_ItemBeingDroppedPhys = false;
12064 }
12065
12067 {
12068 array<string> zone_names = new array<string>;
12069 GetDamageZones(zone_names);
12070 for (int i = 0; i < zone_names.Count(); i++)
12071 {
12072 SetHealthMax(zone_names.Get(i),"Health");
12073 }
12074 SetHealthMax("","Health");
12075 }
12076
12078 void SetZoneDamageCEInit()
12079 {
12080 float global_health = GetHealth01("","Health");
12081 array<string> zones = new array<string>;
12082 GetDamageZones(zones);
12083 //set damage of all zones to match global health level
12084 for (int i = 0; i < zones.Count(); i++)
12085 {
12086 SetHealth01(zones.Get(i),"Health",global_health);
12087 }
12088 }
12089
12091 bool IsCoverFaceForShave(string slot_name)
12092 {
12093 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12094 }
12095
12096 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12097 {
12098 if (!hasRootAsPlayer)
12099 {
12100 if (refParentIB)
12101 {
12102 // parent is wet
12103 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12104 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12105 // parent has liquid inside
12106 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12107 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
12108 // drying
12109 else if (m_VarWet > m_VarWetMin)
12110 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
12111 }
12112 else
12113 {
12114 // drying on ground or inside non-itembase (car, ...)
12115 if (m_VarWet > m_VarWetMin)
12116 AddWet(-1 * delta * GetDryingIncrement("ground"));
12117 }
12118 }
12119 }
12120
12121 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12122 {
12124 {
12125 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
12126 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
12127 {
12128 float heatPermCoef = 1.0;
12129 EntityAI ent = this;
12130 while (ent)
12131 {
12132 heatPermCoef *= ent.GetHeatPermeabilityCoef();
12133 ent = ent.GetHierarchyParent();
12134 }
12135
12136 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
12137 }
12138 }
12139 }
12140
12141 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
12142 {
12143 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
12144 EntityAI parent = GetHierarchyParent();
12145 if (!parent)
12146 {
12147 hasParent = false;
12148 hasRootAsPlayer = false;
12149 }
12150 else
12151 {
12152 hasParent = true;
12153 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
12154 refParentIB = ItemBase.Cast(parent);
12155 }
12156 }
12157
12158 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
12159 {
12160 // this is stub, implemented on Edible_Base
12161 }
12162
12163 bool CanDecay()
12164 {
12165 // return true used on selected food clases so they can decay
12166 return false;
12167 }
12168
12169 protected bool CanProcessDecay()
12170 {
12171 // this is stub, implemented on Edible_Base class
12172 // used to determine whether it is still necessary for the food to decay
12173 return false;
12174 }
12175
12176 protected bool CanHaveWetness()
12177 {
12178 // return true used on selected items that have a wetness effect
12179 return false;
12180 }
12181
12183 bool CanBeConsumed(ConsumeConditionData data = null)
12184 {
12185 return !GetIsFrozen() && IsOpen();
12186 }
12187
12188 override void ProcessVariables()
12189 {
12190 bool hasParent = false, hasRootAsPlayer = false;
12191 ItemBase refParentIB;
12192
12193 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
12194 bool foodDecay = g_Game.IsFoodDecayEnabled();
12195
12196 if (wwtu || foodDecay)
12197 {
12198 bool processWetness = wwtu && CanHaveWetness();
12199 bool processTemperature = wwtu && CanHaveTemperature();
12200 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
12201
12202 if (processWetness || processTemperature || processDecay)
12203 {
12204 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
12205
12206 if (processWetness)
12207 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12208
12209 if (processTemperature)
12210 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12211
12212 if (processDecay)
12213 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
12214 }
12215 }
12216 }
12217
12220 {
12221 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
12222 }
12223
12224 override float GetTemperatureFreezeThreshold()
12225 {
12227 return Liquid.GetFreezeThreshold(GetLiquidType());
12228
12229 return super.GetTemperatureFreezeThreshold();
12230 }
12231
12232 override float GetTemperatureThawThreshold()
12233 {
12235 return Liquid.GetThawThreshold(GetLiquidType());
12236
12237 return super.GetTemperatureThawThreshold();
12238 }
12239
12240 override float GetItemOverheatThreshold()
12241 {
12243 return Liquid.GetBoilThreshold(GetLiquidType());
12244
12245 return super.GetItemOverheatThreshold();
12246 }
12247
12248 override float GetTemperatureFreezeTime()
12249 {
12250 if (HasQuantity())
12251 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
12252
12253 return super.GetTemperatureFreezeTime();
12254 }
12255
12256 override float GetTemperatureThawTime()
12257 {
12258 if (HasQuantity())
12259 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
12260
12261 return super.GetTemperatureThawTime();
12262 }
12263
12265 void AffectLiquidContainerOnFill(int liquid_type, float amount);
12267 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
12268
12269 bool IsCargoException4x3(EntityAI item)
12270 {
12271 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
12272 }
12273
12275 {
12276 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
12277 }
12278
12280 void AddLightSourceItem(ItemBase lightsource)
12281 {
12282 m_LightSourceItem = lightsource;
12283 }
12284
12286 {
12287 m_LightSourceItem = null;
12288 }
12289
12291 {
12292 return m_LightSourceItem;
12293 }
12294
12296 array<int> GetValidFinishers()
12297 {
12298 return null;
12299 }
12300
12302 bool GetActionWidgetOverride(out typename name)
12303 {
12304 return false;
12305 }
12306
12307 bool PairWithDevice(notnull ItemBase otherDevice)
12308 {
12309 if (g_Game.IsServer())
12310 {
12311 ItemBase explosive = otherDevice;
12313 if (!trg)
12314 {
12315 trg = RemoteDetonatorTrigger.Cast(otherDevice);
12316 explosive = this;
12317 }
12318
12319 explosive.PairRemote(trg);
12320 trg.SetControlledDevice(explosive);
12321
12322 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
12323 trg.SetPersistentPairID(persistentID);
12324 explosive.SetPersistentPairID(persistentID);
12325
12326 return true;
12327 }
12328 return false;
12329 }
12330
12332 float GetBaitEffectivity()
12333 {
12334 float ret = 1.0;
12335 if (HasQuantity())
12336 ret *= GetQuantityNormalized();
12337 ret *= GetHealth01();
12338
12339 return ret;
12340 }
12341
12342 #ifdef DEVELOPER
12343 override void SetDebugItem()
12344 {
12345 super.SetDebugItem();
12346 _itemBase = this;
12347 }
12348
12349 override string GetDebugText()
12350 {
12351 string text = super.GetDebugText();
12352
12353 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
12354 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
12355
12356 return text;
12357 }
12358 #endif
12359
12360 bool CanBeUsedForSuicide()
12361 {
12362 return true;
12363 }
12364
12366 //DEPRECATED BELOW
12368 // Backwards compatibility
12369 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12370 {
12371 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
12372 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
12373 }
12374
12375 // replaced by ItemSoundHandler
12376 protected EffectSound m_SoundDeployFinish;
12377 protected EffectSound m_SoundPlace;
12378 protected EffectSound m_DeployLoopSoundEx;
12379 protected EffectSound m_SoundDeploy;
12380 bool m_IsPlaceSound;
12381 bool m_IsDeploySound;
12383
12384 string GetDeployFinishSoundset();
12385 void PlayDeploySound();
12386 void PlayDeployFinishSound();
12387 void PlayPlaceSound();
12388 void PlayDeployLoopSoundEx();
12389 void StopDeployLoopSoundEx();
12390 void SoundSynchRemoteReset();
12391 void SoundSynchRemote();
12392 bool UsesGlobalDeploy(){return false;}
12393 bool CanPlayDeployLoopSound(){return false;}
12395 bool IsPlaceSound(){return m_IsPlaceSound;}
12396 bool IsDeploySound(){return m_IsDeploySound;}
12397 void SetIsPlaceSound(bool is_place_sound);
12398 void SetIsDeploySound(bool is_deploy_sound);
12399
12400 [Obsolete("Use ItemSoundHandler instead")]
12402 void PlayAttachSound(string slot_type)
12403 {
12404 if (!g_Game.IsDedicatedServer())
12405 {
12406 if (ConfigIsExisting("attachSoundSet"))
12407 {
12408 string cfg_path = "";
12409 string soundset = "";
12410 string type_name = GetType();
12411
12412 TStringArray cfg_soundset_array = new TStringArray;
12413 TStringArray cfg_slot_array = new TStringArray;
12414 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
12415 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
12416
12417 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
12418 {
12419 for (int i = 0; i < cfg_soundset_array.Count(); i++)
12420 {
12421 if (cfg_slot_array[i] == slot_type)
12422 {
12423 soundset = cfg_soundset_array[i];
12424 break;
12425 }
12426 }
12427 }
12428
12429 if (soundset != "")
12430 {
12431 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
12432 sound.SetAutodestroy(true);
12433 }
12434 }
12435 }
12436 }
12437
12438 void PlayDetachSound(string slot_type) {}
12439}
12440
12441EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
12442{
12443 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
12444 if (entity)
12445 {
12446 bool is_item = entity.IsInherited(ItemBase);
12447 if (is_item && full_quantity)
12448 {
12449 ItemBase item = ItemBase.Cast(entity);
12450 item.SetQuantity(item.GetQuantityInit());
12451 }
12452 }
12453 else
12454 {
12455 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
12456 return NULL;
12457 }
12458 return entity;
12459}
12460
12461void SetupSpawnedItem(ItemBase item, float health, float quantity)
12462{
12463 if (item)
12464 {
12465 if (health > 0)
12466 item.SetHealth("", "", health);
12467
12468 if (item.CanHaveTemperature())
12469 {
12470 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
12471 if (item.CanFreeze())
12472 item.SetFrozen(false);
12473 }
12474
12475 if (item.HasEnergyManager())
12476 {
12477 if (quantity >= 0)
12478 {
12479 item.GetCompEM().SetEnergy0To1(quantity);
12480 }
12481 else
12482 {
12483 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
12484 }
12485 }
12486 else if (item.IsMagazine())
12487 {
12488 Magazine mag = Magazine.Cast(item);
12489 if (quantity >= 0)
12490 {
12491 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
12492 }
12493 else
12494 {
12495 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
12496 }
12497
12498 }
12499 else
12500 {
12501 if (quantity >= 0)
12502 {
12503 item.SetQuantityNormalized(quantity, false);
12504 }
12505 else
12506 {
12507 item.SetQuantity(Math.AbsFloat(quantity));
12508 }
12509
12510 }
12511 }
12512}
12513
12514#ifdef DEVELOPER
12515ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
12516#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()