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

◆ CanBeCooked()

bool SpawnItemOnLocation::CanBeCooked ( )
protected

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

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