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

◆ IsItemBase()

override bool SpawnItemOnLocation::IsItemBase ( )
protected

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

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

Используется в IEntity::CanBeIgnoredByDroppedItem().